From: Mark Brown <broonie@tardis.ed.ac.uk>
Subject: Re: Why does my C Realloc() fail?
Date: 1998/04/11 [thread overview]
Message-ID: <m3vhsgb3q5.fsf@cassiel.ddns.org> (raw)
In-Reply-To: 352d36a9.0@calwebnnrp
biju@web1.calweb.com (Biju Srinivasan) writes:
> Why does my C realloc() fail?
> A single malloc works for as big as 134 MBytes.
> Realloc fails for a size of 101 MBytes following an alloc of 100 MBytes.
> Doesn't realloc claim the space assigned to the original pointer and add
> extra space to it?
It needn't. realloc() may simply work by getting the amount of memory
you requested and copying the data from the pointer you passed
(there's not even any requirement that it free the existing memory,
although there are very valid quality of implementation issues with an
implementation that doesn't).
To understand why the implementation would do this, consider the case
where thee is a block of memory allocated immediately after the one
being realloc()ed. How could one both increase the size of the first
block and keep pointers to the second block valid?
You are almost certainly going to need to try to process the data in
smaller sections - 100MB of memory is an awful lot of memory to be
using.
[followups to comp.lang.c - I've no idea about how OSF/1 handles this]
--
Mark Brown mailto:broonie@tardis.ed.ac.uk (Trying to avoid grumpiness)
http://www.tardis.ed.ac.uk/~broonie/
EUFS http://www.ed.ac.uk/~filmsoc/
next prev parent reply other threads:[~1998-04-11 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
1998-04-11 4:00 ` Mark Brown [this message]
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