[fpc-pascal]Another pointer related question

Peter Vreman pfv at cooldown.demon.nl
Mon Oct 22 22:04:10 CEST 2001

> > Dispose is supposed to free the whole memory block pointed by the
> > pointer, so it has to know exactly what structure it references to
> > (otherwise it wouldn't know how many bytes were occupied originally).
> > Consequently, it cannot be used with a generic pointer parameter,
> > only with some actual, typed one.
> I was afraid it was going to be something like that. I had hoped that by
> merely referencing the pointer I could just reclaim all the memory it was
> using, regardless of the structure. Sigh...



works fine. The heap manager knows about the size of each allocation and
can therefor free the correct amount of memory. The following code will
even give a runtime error:



More information about the fpc-pascal mailing list