[Solved] In C under what circumstances would the function realloc return Null? [closed]


When the realloc function can’t get more memory to expand the block to the size you asked for. This is either because there is literally no memory available, or the virtual space is exhausted (e.g. a 32-bit application on a 64-bit machine with 16GB of RAM still can’t use more than 4GB in the process space).

It MAY also return NULL if the new size is 0.

Note that in Linux (and possibly other OS’s), when running on a system with limited memory (that is, the memory size is smaller than the virtual memory size), you are more likely to have your process killed by OOM-killer than receive a NULL pointer.

1

solved In C under what circumstances would the function realloc return Null? [closed]