View source code
Display the source code in core/memory.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function core.memory.GC.calloc
Requests an aligned block of managed memory from the garbage collector,
which is initialized with all bits set to zero. This memory may be
deleted at will with a call to free
, or it may be discarded and cleaned
up automatically during a collection run. If allocation fails, this
function will call onOutOfMemory which is expected to throw an
OutOfMemoryError.
Prototype
static void* calloc( ulong sz, uint ba = 0u, const(TypeInfo) ti = null ) pure nothrow;
Parameters
Name | Description |
---|---|
sz | The desired allocation size in bytes. |
ba | A bitmask of the attributes to set on this block. |
ti | TypeInfo to describe the memory. The GC might use this information
to improve scanning for pointers or to call finalizers. |
Returns
A reference to the allocated memory or null if insufficient memory is available.
Throws
OutOfMemoryError on allocation failure.
Authors
Sean Kelly, Alex Rønne Petersen