Issue with using realloc()

Using arm-none-eabi-gcc on linux.

I am using realloc() on a M3 and find that it does not seem to free the unused blocks ?

Here is the sequence I use:
uint8_t a = malloc(1000); 
uint8_t b = realloc(a, 100); // at this point i expect 900 bytes free in the heap. But mallinfo() shows all 1000 in use ?
uint8_t c = malloc(100); // malloc asks for an extra 100 bytes at this point and total heap size becomes 1100 bytes.
It appears that malloc c requests for an extra 100 bytes even though the heap should have 900 bytes remaining from the realloc. Am I doing something incorrect ? 

Parents Reply Children
No data
More questions in this forum