Re: malloc realloc and pointers
- From: "cr88192" <cr88192@xxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 14:44:01 +1000
"K. Jennings" <kjennings@xxxxxxxxxxxxxx> wrote in message
news:pan.2007.11.30.03.44.02@xxxxxxxxxxxxxxxxx
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()?
then, if you are the program, ninjas run up, kick you somewhere painful, and
insert a corncob somewhere painful.
one then has to try to hobble off to the bathroom for a 'core dump'...
.
- References:
- malloc realloc and pointers
- From: ravi
- Re: malloc realloc and pointers
- From: Kenneth Brody
- Re: malloc realloc and pointers
- From: K. Jennings
- malloc realloc and pointers
- Prev by Date: Re: Which functions act as memory barriers?
- Next by Date: Re: Reading a table
- Previous by thread: Re: malloc realloc and pointers
- Next by thread: Re: malloc realloc and pointers
- Index(es):
Relevant Pages
|
|