GC.calloc

David d at dav1d.de
Thu Jul 18 02:55:15 PDT 2013


Am 18.07.2013 02:21, schrieb Andrei Alexandrescu:
> On 7/17/13 1:33 PM, bearophile wrote:
>> Sean Kelly:
>>
>>> I'd like to eliminate GC.calloc entirely. I'd rather have an
>>> allocation routine that takes a TypeInfo and uses that to initialize
>>> the block rather than just doing a memset(0) as per calloc.
>>
>> I think both are needed. The GC calloc is probably handy in some cases.
> 
> I don't find it all that useful as it's really an allocation followed by
> a fill.
> 
> Andrei
> 
> 

I use it all the time, e.g. I have an array of blocks (65536*12Byte) and
I don't want the GC to care about this chunk of data (since it exists up
to 961 times) but I can't just have it filled with random data ->
calloc. Often when I was relativly new to C I always called malloc
followed by a memset to 0, until I learned about calloc (but that's
getting offtopic).


More information about the Digitalmars-d mailing list