The simpliest is to keep the size with the allocated blocks: allocate a
word more than requested, to store the size, and return the addess of the
first byte after the size. You may want to still return aligned pointers
so you may want to store the size on a smaller alignment.
Another solution, you could use it for small blocks, is to allocate blocks
of specific sizes from specific "pages", or superblock, where you can keep
a block size and a bitmap of allocater blocks inside the superblock. I
would do that for blocks up two or three words.
--
__Pascal J. Bourguignon__