Re: when can realloc fail?
- From: Barry Schwarz <schwarzb@xxxxxxxxx>
- Date: Sun, 01 Apr 2007 14:11:20 -0700
On 1 Apr 2007 11:50:05 -0700, banansol@xxxxxxxxxxxx wrote:
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?
It returns NULL if the space cannot be allocated. Whether it is due
to an error or not is something else.
But a call to realloc() with size set to zero is equivalent to free(),
with returns void.
No it is not. Read the last sentence of 7.20.3 again.
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?
No. Success is not guaranteed.
Thanks!
Remove del for email
.
- References:
- when can realloc fail?
- From: banansol
- when can realloc fail?
- Prev by Date: Re: Recursive functions
- Next by Date: Re: Equivalent malloc with calloc
- Previous by thread: Re: when can realloc fail?
- Next by thread: Re: when can realloc fail?
- Index(es):
Relevant Pages
|