may gc free malloced memory?

Alexandr Druzhinin drug2004 at bk.ru
Wed Sep 11 22:36:30 PDT 2013


Some C function malloc-ed memory. This memory should be freeed much 
later. I don't want to manually call C function to free this memory in 
some point later, so may I in some way ask gc to free this memory using 
something like addRoot(for instance) or else or the true way is to copy 
malloc-ed memory to gc-allocated memory and free malloc-ed memory at 
once? Like:

ubyte data* = cfunction_allocates_memory();
auto gcmemory = data[0..length(data)];
cfunction_frees_memory(data);
// work with gcmemory only

or

ubyte data* = cfunction_allocates_memory();
GC.someUnknownToMeFunction(data); // now gc will control this memory


More information about the Digitalmars-d-learn mailing list