[Issue 15986] [std.experimental.allocator.mallocator] calloc?

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 3 08:25:01 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15986

--- Comment #3 from Jack Stouffer <jack at jackstouffer.com> ---
(In reply to JVortex from comment #2)
> mmm.. that makes sense but, does makeArray use calloc (C Heap) instead of
> GC?

Sure

---------------
void main() @nogc
{
    import std.experimental.allocator : makeArray, dispose;
    import std.experimental.allocator.mallocator : Mallocator;

    auto alloc = Mallocator.instance;

    // allocate an array of three ints initialized to zero on the heap and
    // deallocate it once the program leaves the current scope.
    auto array = alloc.makeArray!int(3);
    scope(exit) alloc.dispose(array);
}
--------------

I'm closing this now as this seems to be a misunderstanding. If you have
questions in the future, don't hesitate to ask on
https://forum.dlang.org/group/learn 

Also the allocator page provides a good introduction
https://dlang.org/phobos/std_experimental_allocator.html

--


More information about the Digitalmars-d-bugs mailing list