Afficher un message
Vieux 18/10/2007, 14h35   #7
CBFalconer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is realloc good form ?

vipvipvipvip.ru@gmail.com wrote:
> "christian.bau" <christian....@cbau.wanadoo.co.uk> wrote:
>
>> It depends. realloc will often be clever enough to realise that
>> it can just use the previous block of data without any change.
>> So if you pass in the same Size or similar Size values (like
>> 10000, 10001, 9999) it will be fast. However, if a new block is
>> allocated, all the data will be copied from the previous block
>> to the new block, because that is what realloc does. That might
>> be quite wasteful.

>
> realloc tries not to copy the data, just resize the available
> block of memory.


That depends on the malloc/free/realloc package, and is not
guaranteed. One package that goes to lengths to avoid copying is
nmalloc for DJGPP and similar, available at:

<http://cbfalconer.home.att.net/download/>

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>



--
Posted via a free Usenet account from http://www.teranews.com

  Réponse avec citation
 
Page generated in 0,35864 seconds with 9 queries