From: eqtr0b@deepforest.org (Exil Q Trob)
Subject: Re: Why does my C Realloc() fail?
Date: 1998/04/10 [thread overview]
Message-ID: <6gjt9v$gmp@cnn.genmagic.com> (raw)
In-Reply-To: 352d36a9.0@calwebnnrp
In article <352d36a9.0@calwebnnrp>, biju@web1.calweb.com says...
>
>Doesn't realloc claim the space assigned to the original pointer and add
>extra space to it?
Only if it *can*. It is perfectly legal for an implementation to never even
try to do this.
>A single malloc works for as big as 134 MBytes.
>Realloc fails for a size of 101 MBytes following an alloc of 100 MBytes.
I worked on a system, a few years back, where this sequence would have
failed. Let's assume that 134MB can work because that's all the free space
that the OS has to give the application.
So the app asks for 100MB, and the OS gives it a block that big.
Then it reallocs for 101MB. That won't fit in the current block -- so ask
the OS for a block it will fit in. But the OS has only 34MB available -- can't
make 101 from that.
Note that there's no mechanism for joining a block previously obtained from
the OS to a new block. It seems to me that any such mechanism would be
terribly brittle, subject to easy breakage.
David G
next prev parent reply other threads:[~1998-04-10 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-09 4:00 Why does my C Realloc() fail? Biju Srinivasan
1998-04-09 4:00 ` Dann Corbit
1998-04-10 4:00 ` Christopher Green
1998-04-10 4:00 ` Exil Q Trob [this message]
1998-04-11 4:00 ` Mark Brown
1998-04-22 4:00 ` Jeff Donsbach
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox