Re: malloc realloc and pointers
- From: "K. Jennings" <kjennings@xxxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 03:44:05 GMT
On Thu, 29 Nov 2007 17:00:05 -0500, Kenneth Brody wrote:
ravi wrote:
2. With realloc(), if some pointer 'ptr' is pointing initially to a
perticular position in a buffer (char *buffer) then on performing a
realloc() on this buffer, what will be 'ptr' pointing to?
Three possibilities:
1) realloc() returns the same pointer, in which case ptr is still
valid, pointing to the newly-sized buffer.
2) realloc() returns a different pointer, in which case ptr is
no longer valid, and must not be dereferenced.
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()?
.
- Follow-Ups:
- Re: malloc realloc and pointers
- From: Keith Thompson
- Re: malloc realloc and pointers
- From: CBFalconer
- Re: malloc realloc and pointers
- From: cr88192
- Re: malloc realloc and pointers
- References:
- malloc realloc and pointers
- From: ravi
- Re: malloc realloc and pointers
- From: Kenneth Brody
- malloc realloc and pointers
- Prev by Date: Re: memcat fn
- Next by Date: Re: Which functions act as memory barriers?
- Previous by thread: Re: malloc realloc and pointers
- Next by thread: Re: malloc realloc and pointers
- Index(es):
Relevant Pages
|