Re: malloc realloc and pointers



"K. Jennings" <kjennings@xxxxxxxxxxxxxx> writes:
[...]
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?
[snip]
What happens when ptr is not one returned by a previous
invocation to malloc(), calloc() or realloc()?

Undefined behavior.

(This is partly a test of news-server.san.rr.com.)

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: append to the recv socket buffer
    ... I am also trying to minimize the amount of times I call malloc ... Another thing is that even if I have a buffer for each ... int sizeOfNextMsg; ...
    (comp.unix.programmer)
  • Re: fseek on a file opened with _popen
    ... Do you mean ftell() here? ... and react accordingly (I cannot malloc the buffer beforehand. ... and about compiled Seed7 programs. ...
    (comp.lang.c)
  • Re: C 99 compiler access
    ... > nm> reliably allocating some piece of memory. ... We're not talking about implementing malloc in portable C - it's part of the ... concern is that library implementations are not implementing the required ... using malloc to allocate the buffer memory. ...
    (comp.lang.c)
  • Re: Benchmark: STLs list vs. hand-coded one
    ... if you bother to check the pointer from malloc or use newand throw ... buffer to 640MBytes. ... To support your efficient memory management you limit symbol size to ... Yes you could require the compiler to jump ...
    (comp.arch.embedded)
  • Re: fseek on a file opened with _popen
    ... Do you mean ftell() here? ... and react accordingly (I cannot malloc the buffer beforehand. ... more memory to get each time when the initial buffer isn't enough. ...
    (comp.lang.c)