Changes to the Tango runtime / GC

Sean Kelly sean at f4.ca
Mon Oct 15 16:39:53 PDT 2007


Bruno Medeiros wrote:
> 0ffh wrote:
>> Bruno Medeiros wrote:
>>> So, is there a way to allocate an uninitialized byte[] that has 
>>> hasPointer set to false?
>>
>> I'd say byte[] defaults to hasPointers=false, so you wouldn't
>> have to do anything special to make it so.
>> (It is the void[] that usually has hasPtrs=true.)
> 
> Agh nevermind, I thought the purpose of allocating void[] was to 
> allocate an uninitialized array, but that's what the void initializer 
> does instead. void[] is the same as byte[] but with hasPointers=true 
> then? I couldn't find about that in the doc.

I don't think it is in the docs, but it is in the 1.0x changelog 
somewhere.  The only other difference is that, like void*, void[] can 
accept some other types of data without a cast.  As far as I know, there 
is no way to allocate an uninitialized dynamic array using 'new' though. 
  I don't imagine this works?

     byte[] x = new byte[8] = void;

This is one reason that Tango offers access to GC.malloc and GC.calloc 
routines as a means to directly allocate either uninitialized or 
zero-initialized memory.


Sean



More information about the Digitalmars-d mailing list