Updates to the containers library

J

jacob navia

I have been reworking the heap allocation module. This module should be
the base of many containers since it is specialized in allocating a lot
of objects all of the same size.


I have discarded the bitmap I maintained to track the free list for a
slightly more sophisticated approach.

I allocate a table of pointers to pages of CHUNK_SIZE objects. Since one
of the constraints is that no active object can be moved, it is not
possible to just allocate a single strip of objects and reallocate it
later. The reason for maintaining active objects fixed is that user
pointers to those objects could exist and that there is no way to
update those if the object is moved.

The organization is then :

A resizable vector of pointers that holds the start addresses of pages
of a fixed quantity of allocated objects.

When an object is freed, its "Next" pointer will be updated to
contain INVALID_POINTER_VALUE, that for the time being I have defined
as ((void *)~0ULL). This allows me to distinguish active objects
from freed ones, assuming that all client objects have a pointer at
their first position. This is always true for the containers, but limits
the interest of this schema for other uses.

The heap contans an implementation of iterators, that allow a client
program to visit all objects in the heap. Since all complex containers
like trees, (scapegoat trees) and others use a heap, I get an
implementation of iterators in all those containers for free without
having to write an iterator for each one.


The source code is available at

http://code.google.com/p/ccl/

The code size has been reduced: all the heap object takes now
around 1500 bytes of code in a x86.

jacob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top