I am currently working on an assignment that manages user's requests for memory. I are basically developing the procedures to replace malloc() and free(). I am supposed to maintain a free_list that holds a record of available memory blocks(obtained via sbrk()), and when a user requests a memory block, the free_list is checked for an available block, and if it isn't available, then a new block is obtained, added to the free_list, then checked again.

This is where I am having a problem. When adding a new block to the free_list, which I am implementing as a circular linked list, I am passing the Free() function a void pointer to the newly acquired memory block.

My question is this: how do I know how large is the memory block being pointed to?

This is necessary to know so when my Malloc() function searches the list, this new block's size can be seen.

Sorry for the long question, I just seem to be stuck on this point. If you want any code examples or further explanation, please let me know.

Thanks in advance.