Re: when can realloc fail?
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Sun, 01 Apr 2007 21:58:19 -0400
Nelu wrote:
.... snip ...
In C99 it only returns NULL when it fails. If it returns non-null
and the size is 0 then it will return an address to a block of
memory of zero size. The address *will not be NULL* and you will
have to free it using free().
Not so. C99 specifically allows a successfull realloc(p, 0) or
malloc(0) to return NULL. I consider systems that use this to be
flawed, yet portable code has to allow for it.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: when can realloc fail?
- From: Nelu
- Re: when can realloc fail?
- From: Eric Sosman
- Re: when can realloc fail?
- References:
- when can realloc fail?
- From: banansol
- Re: when can realloc fail?
- From: Eric Sosman
- Re: when can realloc fail?
- From: banansol
- Re: when can realloc fail?
- From: Nelu
- when can realloc fail?
- Prev by Date: Re: About Union's question
- Next by Date: Re: Reading a key inside a loop
- Previous by thread: Re: when can realloc fail?
- Next by thread: Re: when can realloc fail?
- Index(es):
Relevant Pages
|