This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] bitmap_allocator.


Dhruv Matani wrote:

Ok. Let me explain what I am trying to do: I have a pointer to some type T which is not the one parameterizing the
allocator.


A *very down to earth* proposal: can't you simply stop referring internally
to unsigned int (T is unsigned int currently, right?) which is only 16 bits both
on 32-bit and 64-bit machines? Can't you just use a wider type? Long would
do much better, I'm sure, since it's 8 bytes on 64-bit machines, and, possibly,
if the user wants to configure for the best alignment, you could just consider
pairs of those objects as your basic internal units.


Also, remember that if you allocate bookkeeping data in the memory returned
by ::operator new, that data must also be aligned according to its type and then,
in general, you need padding between that data and your usable memory: f.i.,
if you store a single int in an header, you need, for best alignement, 4 bytes
(or 12 bytes) of padding in the middle.


Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]