I have a char array that I'm using as a memory pool. I already have all the bytes flagged to signify that they are free/not free. My question is how do I go about allocating 4 bytes of the array for each int?
Small example of how I'm thinking this will work:
void* block;
char memPool[50];
block = &memPool[0];
return block;
This will return a pointer to a location that is big enough to hold 1 byte if I'm thinking correctly. So maybe I can use a void* array of 4 bytes instead and loop through the bytes until I get to the sizeof whatever type I'm being passed. I'm just trying to get this hashed out on paper before I sit down and start coding it.
I'm just looking for a bit of insight. Thanks.
Copyright Notice:Content Author:「Riley F」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15856165/how-to-allocate-specific-number-of-bytes-in-a-char-array-memory-management