[fpc-devel] StrDispose FreeMem with size

Daniël Mantione daniel.mantione at freepascal.org
Fri Oct 13 10:04:25 CEST 2006



Op Fri, 13 Oct 2006, schreef Micha Nelissen:

> Dani=EBl Mantione wrote:
> > 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.
> =

> Oh ok, I didn't know; thought it was like an assertion check. But why is =
there
> a FreeMemSize in the heap manager then ? It could've been:
> =

> function FreeMemSize(P: pointer; S: ptrint): ptrint;
> begin
> { ignore S: cannot free blocks partially }
> Result :=3D FreeMem(P);
> end;
> =

> I think no recent heap manager can free blocks partially ?

I think the idea is that if you want, you can write and install a heap =

manager that uses the size. In such case you implement =

freemem(pointer,size), and freemem(pointer) then results in a runtime =

error.

Dani=EBl


More information about the fpc-devel mailing list