www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/22/20:34:30

Date: Mon, 22 Jan 2001 20:33:03 -0500
Message-Id: <200101230133.UAA04780@envy.delorie.com>
X-Authentication-Warning: envy.delorie.com: dj set sender to dj AT envy DOT delorie DOT com using -f
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <8kjp6tohorretgu7fadnh7889ub8ihfj4d@4ax.com> (message from Damian
Yerrick on Tue, 23 Jan 2001 00:19:58 GMT)
Subject: Re: Advance warning of failure of realloc()
References: <8kjp6tohorretgu7fadnh7889ub8ihfj4d AT 4ax DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> To expand an allocated memory block, I should use realloc().  But if
> realloc() fails, I lose the contents of the block, correct?  How can
> I prevent irretrievable data loss when calling realloc()?

Call malloc() and copy the data yourself.  Not a perfect solution, as
realloc reuses the current chunk if it can.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019