More local heap references

Collecting yet more references for implementing a custom heap for C++. One of the issues you run into when using a custom heap is the notion of placement new: void *operator new (size_t size, Heap &heap) { return heap.Allocate(size); }

Object allocations now appear so:

Heap local; obj *p = new (local) obj();

And when deleting the memory you must ensure that you give it back to the heap:

operator delete(p, local);

That last part makes the system less friendly. You can however override the operator new and delete for ‘obj’ and give it knoledge of a local heap.

More references:

This entry was posted in c++, programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>