1

realloc without freeing old memory

view story
linux-howto

http://stackoverflow.com – I want to use realloc to increase memory size while keeping the pointer unchanged (because the callers uses it). realloc does not always do that; sometimes it returns a different pointer and frees the old one. I would like to "try" to realloc memory and if it is not possible, fallback to a different method using the original pointer - but realloc has already destroyed that! Is there a way to try to increase malloc'ed memory without destroying (as realloc does) the old pointer if it is not possible? E.g. void *pold; void *pnew = realloc(pold, newsize); if (pnew != pold) { free(pnew); (HowTos)