A "simple" realloc() question.

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Jun 17 07:17:25 AEST 1989


In article <1606 at csm9a.UUCP> ddale at csm9a.UUCP (Doug Dale) writes:
>When using realloc(), if it is necessary to move the information to
>another location in memory because more memory is needed, is the old
>memory freed?

Yes -- realloc() moves the one-and-only instance of the data to a
possibly new location; the former pointer (from an earlier malloc() or
realloc()) is no longer usable when realloc() returns successfully.
(If realloc() returns unsuccessfully, then the data is supposed to
still be where it was and the previous pointer remains valid.)



More information about the Comp.lang.c mailing list