[fpc-pascal] New Dispose and FreeMem and objects

Andrew Haines AndrewD207 at aol.com
Fri Aug 26 22:39:11 CEST 2011


Hi is the following allowed or will it cause problems:

type

PObj = ^TObj;
TObj = object
  constructor Init;
end;

var
 Obj : PObj;
begin
 Obj := new(PObj, Init);
 FreeMem(Obj); // This is the line I wonder about.
end;

I compiled this and it doesn't throw any exceptions.

Should I only use Dispose(Obj) ?

Maybe Dispose can call a destructor and that is the difference between
Dispose and FreeMem?



Thanks,

Andrew Haines



More information about the fpc-pascal mailing list