-1

I can't understand how to properly free the memory by pointer a

MemoryManager mm;
char* a = new(mm) char[len];
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084

1 Answers1

0

You just call the destructor (if needed) and deallocate with your memory manager

// Deallocate memory
MemoryManager.free(a);

Or, you could define a delete operator for your custom allocator:

void operator delete(void *ptr, const MemoryManager &m) {...}
...
operator delete(a, mm);
unexpectedvalue
  • 6,079
  • 3
  • 38
  • 62