A "simple" realloc() question.

richard.r.grady..jr r4 at cbnews.ATT.COM
Fri Jun 16 04:24:50 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?  

I looked through the code for realloc() on my machine (System V Rel 2).
The algorithm is:

    if( old_pointer is not free )
        free( old_pointer )
    new_pointer = malloc( new_size )
    etc. ...

Yes, the old memory is freed.

-------------------------------------------------------------------
Dick Grady               r4 at mvuxd.att.com          ...!att!mvuxd!r4 



More information about the Comp.lang.c mailing list