1 module std.database.allocator; 2 //import std.experimental.allocator.common; 3 import std.experimental.logger; 4 5 struct MyMallocator { 6 //enum uint alignment = platformAlignment; 7 8 @trusted // removed @nogc and nothrow for logging 9 void[] allocate(size_t bytes) { 10 import core.stdc.stdlib : malloc; 11 if (!bytes) return null; 12 auto p = malloc(bytes); 13 return p ? p[0 .. bytes] : null; 14 } 15 16 /// Ditto 17 @system // removed @nogc and nothrow for logging 18 bool deallocate(void[] b) { 19 import core.stdc.stdlib : free; 20 //log("deallocate: ptr: ", b.ptr, "size: ", b.length); 21 free(b.ptr); 22 return true; 23 } 24 25 } 26