Custom Memory Manager
<p>I am trying to implement a custom memory manager and I am wondering if there is a better way to implement this function, as when I am  asked about void pointer arithmetic, several people thought that if I had a void* in C++, something was very wrong.</p>

<pre><code>// allocates a page of memory.
void ObjectAllocator::allocatePage()
{    
    //if(OAStats_.PagesInUse_ &gt;= Config_.MaxPages_)
        //throw exception

    void* buffer = ::operator new(OAStats_.PageSize_); // allocate memory, no constructor call.

    // =============== Setup the PageList_ ===============
    GenericObject* pNewNode = ::new(buffer) GenericObject();    // Construct GenericObject for the pagelist.
    pNewNode-&gt;Next = PageList_-&gt;Next;                            // pNewNode points to wherever PageList_ pointed to.
    PageList_-&gt;Next = pNewNode;                                    // PageList_ points to pNewNode
    pNewNode = NULL;                                            // dont need this handle anymore
    buffer = static_cast&lt;char*&gt;(buffer) + sizeof(GenericObject);    // move pointer to point after the generic object.

    // =============== Setup the FreeList_ ===============
    for(int i=0;i&lt;Config_.ObjectsPerPage_;++i)
    {
        static GenericObject* pPreviousNode = NULL;            // static variable to hold the previous node
        pNewNode = ::new(buffer) GenericObject();            // Construct GenericObject for the freelist.
        pNewNode-&gt;Next = pPreviousNode;
        pPreviousNode = pNewNode;
        buffer = static_cast&lt;char*&gt;(buffer) + OAStats_.ObjectSize_;    // move pointer by ObjectSize.
        ++OAStats_.FreeObjects_;
    }
    FreeList_-&gt;Next = pNewNode;

    ++OAStats_.PagesInUse_;
    ++OAStats_.Allocations_;
}
</code></pre>
