Quick int pointer allocation question

monarch_dodra monarchdodra at gmail.com
Fri Sep 14 12:23:40 PDT 2012


On Friday, 14 September 2012 at 14:27:43 UTC, monarch_dodra wrote:
> On Friday, 14 September 2012 at 11:17:55 UTC, Jacob Carlborg 
> wrote:
>>
>> Perhaps using GC.malloc?
>
> Hum, apparently, there is a second (default aka-hidden) 
> argument that is a bitmask applied to the allocated memory. So 
> not much gain there.
>
> I'm allocating an array of 500_000 ulongs, and afterwards, I'm 
> initializing them all "by hand", making the default allocation 
> useless.
>
> I'm not going to lose any sleep over this, but there is no way 
> in D to get (garbage collected) un-initialized 
> memory/allocations?

Never mind, I misread the doc. The bitmask is not memcopied, it 
is actually just a mask of options, so GC works perfectly.

Anybody know what the attribute "FINALIZE" (Finalize the data in 
this block on collect) means?

On Friday, 14 September 2012 at 18:14:54 UTC, bearophile wrote:
> monarch_dodra:
>
>> I'm allocating an array of 500_000 ulongs, and afterwards, I'm 
>> initializing them all "by hand", making the default allocation 
>> useless.
>
> In std.array there are two functions to avoid a double 
> initialization, mostly to be used for nonreference data.
>
> Bye,
> bearophile
I was looking for those actually, but I was looking in 
std.algorithm...

Thanks


More information about the Digitalmars-d-learn mailing list