[lazarus] Trying to port a Delphi graph

Peter Vreman peter at freepascal.org
Mon Mar 31 00:01:53 EST 2003


>> >
>> >I'm not familiar with the DISPOSE keyword or function.  Can someone
>> help
>> >me decipher what is supposed to be happening here?
>>
>> Dispose is the opposite of New.
>>
>> With New you can allocate dynamic variables like:
>>
>> var
>>    P: PMyRecord
>> begin
>>    New(P);
>>
>> if you don't need your variable anymore you should use Dispose to fee
>> memory
>> In this case Dispose(P);
>>
>> FPC in your case complains, since it doesn't know how to dispose a
>> pointer.
>> You can avoid that by casting FTrapezes[i] to the PointerType it
>> contains
>
> Delphi accepts it, then so should FPC.  I suspect it dates from the time
> of early Delphi
> compability where freemem always had to have a size parameter. It doesn't
> need that anymore
> nowadays, so that would be the same for dispose?

We've to add support for it. But i would say only in Delphi mode since
it's bad coding. To free an untyped pointer you have to use
Freemem(pointer).

Btw. Another difference between Dispose() and Freemem() is that the type
that is passed to dispose() is also used to generate a call to Finalize()







More information about the Lazarus mailing list