Quick int pointer allocation question

Simen Kjaeraas simen.kjaras at gmail.com
Fri Sep 14 10:20:58 PDT 2012


On Fri, 14 Sep 2012 16:27:55 +0200, monarch_dodra <monarchdodra at gmail.com>  
wrote:

> On Friday, 14 September 2012 at 11:17:55 UTC, Jacob Carlborg wrote:
>> On 2012-09-14 12:52, monarch_dodra wrote:
>>
>>>> int x = void;
>>>>
>>>> http://dpaste.dzfl.pl/24c1baa9
>>>
>>> Hum, but that is a stack allocated variable.
>>
>> 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?

What's wrong with GC.malloc? The bitmask is there to... well, many things.
Pass it BlkAttr.NO_SCAN to ensure memory is not initialized. I think that's
all what's needed.

-- 
Simen


More information about the Digitalmars-d-learn mailing list