The C standard does not specify what will happen, so you are at the mercy of the implementation. I canβt imagine a semi-like implementation that will not return the passed pointer, but a safe option is to check if the distribution size has changed in your own code. It will also miss the function call.
(BTW, please do not add the return value from realloc . This is not necessary, and it may hide undefined behavior if you forget #include <stdlib.h> .)
source share