[fpc-devel] StrDispose FreeMem with size

Daniël Mantione daniel.mantione at freepascal.org
Fri Oct 13 09:55:27 CEST 2006



Op Fri, 13 Oct 2006, schreef Micha Nelissen:

> Peter Vreman wrote:
> > > Hi,
> > > 
> > > At cutils line 926, FreeMem is called for p with size strlen(p)+1.
> > > Could
> > > it be that actually a much bigger block was allocated, and not size
> > > strlen(p)+1 ?
> > 
> > The size parameter is ignored by the heap manager.
> 
> That's two bugs, then :).

No, it is a concious decision and Delphi compatible. The TP heap manager 
did not store the size of a block, so the size parameter was necessary. 
It was also possible to free only parts of blocks.

This is not possible with the FPC heap manager, it frees the entire heap 
block. So the size has no function.

Daniël


More information about the fpc-devel mailing list