Re: when can realloc fail?



Joe Wright wrote:

.... snip ...

I have posed a question a little upthread: Given ptr points to an
area to be freed, and then 'realloc(ptr, 0);'. Granted that realloc
can return NULL or not, will the allocation of ptr be freed? I'd
like to think so.

You don't know, which is one more reason to consider such
allocaters to be brain-dead.

--
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

.



Relevant Pages

  • [PATCH] ALSA: Remove subsystem-specific malloc (8/8)
    ... -void snd_magic_kfree(void *_ptr) ... * @flags: allocation conditions, GFP_XXX ... * Returns the pointer, or NULL if no enoguh memory. ...
    (Linux-Kernel)
  • Re: struggling to use calloc and realloc
    ... check that the allocation succeeded before continuing. ... ptr is a pointer to a character. ... Again, lose the cast. ... the memory you originally allocated is now gone forever. ...
    (comp.lang.c)
  • Re: trying to make my "fillvalues" function work...
    ... if (pointer == NULL) ... fputs("Memory allocation failure (%s). ... printErrAllocation(location, ptr); ... Check this error handling by demanding absurdly ...
    (comp.lang.c)
  • Re: A solution for the allocation failures problem
    ... The free function causes the space pointed to by ptr to be ... deallocated, that is, made available for further allocation. ... memory and make it available for other programs/processes/whatever. ... standard, for the most part, describes behavior of a single executing ...
    (comp.lang.c)
  • Re: the & pointer operator to yield an address
    ... this specific function works with the actual pointer passed. ... The reason for passing &ptr is so the function can ... While allocation is certainly one case where you ... Often &ptr is passed to func because func is going to store something ...
    (comp.lang.c)