Original Post
Hey,
If I have allocated some dynamic memory... lets say
int *pInt = (int*)malloc(32*sizeof(int));
And want to split it into smaller parts (yup Memory Management
) How can I come across that problem? Should I just free the allocated memory and then allocated it again in two pieces, where the sum of their size matches the size of the first block??
That wouldn''t create any fragmentation? If I try to visualize it I don''t see the fragmentation...
Heap when the first block is allocated (A is first block and B something completly else)
AAAABBB...
Heap when the block is freed
....BBB...
Heap when I reallocate in smaller chunks
A1A1A2A2BBB...
Any fragmentation?