I wonder if there is a way to check how big the memory area is after malloc and realloc?
This is just to see if realloc really works as expected.
I wonder if there is a way to check how big the memory area is after malloc and realloc?
This is just to see if realloc really works as expected.
You cantīt teach an old dog new tricks.
In short no. If realloc() fails it will return NULL, else it returns a pointer to the memory, size of whatever you asked for.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Ok, thanks.Originally posted by Hammer
In short no. If realloc() fails it will return NULL, else it returns a pointer to the memory, size of whatever you asked for.
You cantīt teach an old dog new tricks.
>>I wonder if there is a way to check how big the memory area is after malloc and realloc?
Save the size you pass to malloc() or realloc() in a variable so you can use it later :-)
>>This is just to see if realloc really works as expected.
They return a null pointer if they fail
Code:if ((p = malloc(mem_size * sizeof(*p))) == 0) { /* Error */ }
*Cela*