From: Richard Dawe Newsgroups: comp.os.msdos.djgpp Subject: Re: Advance warning of failure of realloc() Date: Tue, 23 Jan 2001 21:26:44 +0000 Organization: Customer of Energis Squared Lines: 40 Message-ID: <3A6DF714.DA2C260E@phekda.freeserve.co.uk> References: <8kjp6tohorretgu7fadnh7889ub8ihfj4d AT 4ax DOT com> <3A6CDFE1 DOT 4170CCBA AT uol DOT com DOT br> <200101230144 DOT UAA04861 AT envy DOT delorie DOT com> NNTP-Posting-Host: modem-64.dextromethorphn.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: newsg1.svr.pol.co.uk 980286952 17156 62.136.90.192 (23 Jan 2001 21:55:52 GMT) NNTP-Posting-Date: 23 Jan 2001 21:55:52 GMT X-Complaints-To: abuse AT theplanet DOT net X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.17 i586) X-Accept-Language: de,fr To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello. Damian Yerrick wrote: > > On Mon, 22 Jan 2001 20:44:01 -0500, DJ Delorie wrote: > > > > Save your pointer to the old memory block before attempting to > > > realloc. > > > > DJGPP's code allows this, but I didn't realize you could rely on it. > > Anyone up for a patch to the realloc() docs? I posted a patch to djgpp-workers to clarify what happens to the old memory block, when realloc() fails. This patch was committed to DJGPP CVS on Fri, 27 Oct 2000. Here is the updated description: "Description ----------- This function changes the size of the region pointed to by PTR. If it can, it will reuse the same memory space, but it may have to allocate a new memory space to satisfy the request. In either case, it will return the pointer that you should use to refer to the (possibly new) memory area. The pointer passed may be `NULL', in which case this function acts just like `malloc' (*note malloc::). Return Value ------------ On success, a pointer is returned to the memory you should now refer to. On failure, `NULL' is returned and PTR is not freed." Bye, -- Richard Dawe http://www.bigfoot.com/~richdawe/ "The soul is the mirror of an indestructible universe." --- Gottfried W. Leibniz