[lazarus] Trying to port a Delphi graph

Marc Weustink marc at dommelstein.net
Sun Mar 30 16:38:35 EST 2003


At 15:44 30-3-2003 -0600, Tony Maro wrote:
>I'm trying to port a 3D graph unit I found for Delphi.  I've already
>done much of the conversion (messages and such) but ran into the
>following routine:
>
>Procedure TGraph3D.ClearTrapezes;
>var i : LongInt;
>begin
>   For i := 0 to FTrapezes.Count-1 do begin
>     Dispose(FTrapezes[i]);
>     FTrapezes[i] := nil;
>   end;
>   FTrapezes.Pack;
>end;
>
>FTrapezes is defined as:
>
>FTrapezes : TList;        //casts to PTrapezeInfo
>
>But when it hits the "Dispose" line, I get:
>"Use of NEW or DISPOSE is not possible for untyped pointers"
>
>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

Marc







More information about the Lazarus mailing list