Re: malloc realloc and pointers



"K. Jennings" wrote:

.... snip ...

3) realloc() returns NULL, in which case ptr is pointing to the
unchanged memory region as before.

What happens when ptr is not one returned by a previous
invocation to malloc(), calloc() or realloc()?

Then you know that realloc moved the storage. It doesn't affect
the data held by the pointed to object.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: malloc realloc and pointers
    ... perticular position in a buffer then on performing a ... realloc() returns the same pointer, in which case ptr is still ... pointing to the newly-sized buffer. ...
    (comp.lang.c)
  • Re: malloc realloc and pointers
    ... perticular position in a buffer then on performing a ... realloc() returns the same pointer, in which case ptr is still ... pointing to the newly-sized buffer. ...
    (comp.lang.c)
  • Re: Implementing Realloc
    ... How to implement realloc? ... void *realloc(void *ptr, size_t len) ... store the actual amount requested, in which case you need to set it. ...
    (comp.lang.c)
  • Re: malloc realloc and pointers
    ... perticular position in a buffer then on performing a ... realloc() returns the same pointer, in which case ptr is still ... pointer is identical to the old pointer, you're not allowed to use them ...
    (comp.lang.c)
  • kinda wild ptr??
    ... int main{ ... ptr is pointing to the address after nwhich is not what im expecting... ... how to fix this lil out-of-control ptr... ...
    (comp.lang.cpp)