RE: [xml] Action of realloc

Date view Thread view Subject view Author view

From: David Lofquist (david.lofquist@nwa.com)
Date: Tue Dec 05 2000 - 17:35:15 EST


I believe the standard way to handle this is to call realloc
in the following way:

pStatus = realloc(pOld, newsize);
if (pStatus == NULL) {
    free(pOld);
    etc...
}

If pOld is not used to capture the return from realloc, it is
left intact in the event the call fails.

> -----Original Message-----
> From: Bjorn Reese
>
> JohnnyXia@acersoftech.com.cn wrote:
>
> > pOld = realloc( pOld, newsize );
>
> You are right. If realloc() fails, then the old memory block is
> lost. This behaviour is not restricted to individual platforms,
> but a general ANSI/ISO stdlib behaviour.

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Dec 05 2000 - 17:43:38 EST