Bit of a C++ question here, is there any situation where a call to realloc will fail but an immediate call to malloc will succeed? I know on modern systems memory allocation isn’t usually a problem but in this situation the buffer may be used to hold very large sets of data.
Looking at this realloc reference if realloc can’t simply extend the existing block it will return a new block. In HeapBlock::realloc where does this old block get freed? Wouldn’t we need something like:
void* temp = data;
data = std::realloc (data, newNumElements * elementSize)
if (temp != data)
Or am I missing something fundamental?