Implement own memory pool

Viewed 27742

I want to allocate a certain amount of memory upfront and use that memory for the rest of the program. The program will basically be allocating memory for a few strings and structs. How do I implement this? What data structures are used to store the pointers and how do I use it to give me a specific amount?

For example, if I malloc 1 MB of space and have it in a pointer p, how do I carve out a 250 KB piece from it ?

This is just meant to be a quick and dirty implementation.

2 Answers
Related