mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 13:10:35 +03:00
26 lines
602 B
D
Executable file
26 lines
602 B
D
Executable file
#!/usr/bin/env dub
|
|
/++dub.sdl:
|
|
dependency "phobos:allocator" path=".."
|
|
+/
|
|
|
|
void main(string[] args)
|
|
{
|
|
import stdx.allocator.mallocator : Mallocator; // From latest Phobos
|
|
import std.stdio; // current phobos
|
|
auto buf = Mallocator.instance.allocate(10);
|
|
writeln("allocate: ", buf);
|
|
scope(exit) Mallocator.instance.deallocate(buf);
|
|
}
|
|
|
|
void test()
|
|
{
|
|
import stdx.allocator : make;
|
|
import stdx.allocator.mallocator : Mallocator;
|
|
alias alloc = Mallocator.instance;
|
|
struct Node
|
|
{
|
|
int x;
|
|
this(int, int){}
|
|
}
|
|
auto newNode = alloc.make!Node(2, 3);
|
|
}
|