There's no implementation for a cleared allocation (calloc). Why is that?
Comment #1 by jack — 2016-05-03T14:11:05Z
I'm guessing speed?
Also, I was under the impression that calloc is typically used for making arrays, and std.experimental.allocator wants you to use makeArray for that.
Comment #2 by jv_vortex — 2016-05-03T14:46:32Z
mmm.. that makes sense but, does makeArray use calloc (C Heap) instead of GC? I'm new using custom allocators.
Comment #3 by jack — 2016-05-03T15:25:01Z
(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