when can realloc fail?



Hi,
I just want to get this right.
A call to realloc() will return NULL on error and the original memory
is left untouched,
both when requesting a larger or a smaller size that the original,
right?
But a call to realloc() with size set to zero is equivalent to free(),
with returns void.
Does that mean that a call to realloc() can fail when shinking memory
except when
shrinking it to zero in which case it will always succeed?

Thanks!

.



Relevant Pages

  • Re: when can realloc fail?
    ... A call to reallocwill return NULL on error and the original memory ... But a call to realloc() with size set to zero is equivalent to free, ... Does that mean that a call to realloccan fail when shinking memory ...
    (comp.lang.c)
  • Re: when can realloc fail?
    ... A call to reallocwill return NULL on error and the original memory ... But a call to realloc() with size set to zero is equivalent to free, ...
    (comp.lang.c)
  • Re: when can realloc fail?
    ... A call to realloc() will return NULL on error and the original memory ... both when requesting a larger or a smaller size that the original, ... Remove del for email ...
    (comp.lang.c)
  • Re: realloc and malloc [was: memfrob and strfry ? OT]
    ... The realloc function is called to resize memory pointed to by 'p' to the ... and if realloc fails it would evaluate to false. ... realloc can fail in which case the original memory is left untouched. ... event of realloc failure (unless the value previously in 'p' has been ...
    (comp.lang.c)
  • Re: realloc and malloc [was: memfrob and strfry ? OT]
    ... and if realloc fails it would evaluate to false. ... realloc can fail in which case the original memory is left untouched. ... event of realloc failure (unless the value previously in 'p' has been ... Just plain old ...
    (comp.lang.c)