Re: d malloc

2014-08-09 Thread ketmar via Digitalmars-d-learn
On Sat, 09 Aug 2014 09:08:14 + via Digitalmars-d-learn wrote: > really must use an integral type instead of a pointer, use > `size_t`, which is defined to have the same size as a pointer. ptr_t or uptr_t ;-) that is the reason why the std.string.indexOf() using ptrdiff_t, for example. sign

Re: d malloc

2014-08-09 Thread via Digitalmars-d-learn
On Friday, 8 August 2014 at 18:51:49 UTC, ketmar wrote: Why are void pointers better than ulong, if I may ask there is at least one reason: GC. yes, it is conservative, but there's no reason to scan ulong[] for any pointers, so you may lost your objects if there is no other references to 'em.

Re: d malloc

2014-08-08 Thread ketmar via Digitalmars-d-learn
Why are void pointers better than ulong, if I may ask there is at least one reason: GC. yes, it is conservative, but there's no reason to scan ulong[] for any pointers, so you may lost your objects if there is no other references to 'em.

Re: d malloc

2014-08-08 Thread seany via Digitalmars-d-learn
On Friday, 8 August 2014 at 17:44:29 UTC, anonymous wrote: On Friday, 8 August 2014 at 17:07:37 UTC, seany wrote: And as discussed earlier, I was trying to save the pointers in an ulong (which is same as size_t or ptr_t, those are aliased) (when compiling for x86-64 that is) Generally, castin

Re: d malloc

2014-08-08 Thread ketmar via Digitalmars-d-learn
On Fri, 08 Aug 2014 16:42:12 + seany via Digitalmars-d-learn wrote: a) we need the working code; b) foreach (a; ...) doest struct copying, and you see the temporary stack object as 'a'. either use 'ref a', or don't do that at all. that is what i was able to understand from your code. signa

Re: d malloc

2014-08-08 Thread anonymous via Digitalmars-d-learn
On Friday, 8 August 2014 at 17:07:37 UTC, seany wrote: And as discussed earlier, I was trying to save the pointers in an ulong (which is same as size_t or ptr_t, those are aliased) (when compiling for x86-64 that is) Generally, casting pointers to size_t is a horrible idea. Why can't you at le

Re: d malloc

2014-08-08 Thread seany via Digitalmars-d-learn
On Friday, 8 August 2014 at 16:51:37 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, Aug 08, 2014 at 04:42:12PM +, seany via Digitalmars-d-learn wrote: consider this : struct S { /* ... */ } void main() { ulong [] u; for(// ... { S s_instance; // fillup .. S.k

Re: d malloc

2014-08-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 08, 2014 at 04:42:12PM +, seany via Digitalmars-d-learn wrote: > consider this : > > struct S > { > /* ... */ > > } > > void main() > { >ulong [] u; > >for(// ... >{ > S s_instance; > // fillup .. S.key = value; > u ~= cast(ulong)*s_instance; >}

d malloc

2014-08-08 Thread seany via Digitalmars-d-learn
consider this : struct S { /* ... */ } void main() { ulong [] u; for(// ... { S s_instance; // fillup .. S.key = value; u ~= cast(ulong)*s_instance; } } however, the structs are being allocated to the same place. Because, Every time the iterator ends an iterati