[fpc-pascal] New Dispose and FreeMem and objects

2011-08-26 Thread Andrew Haines
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

Re: [fpc-pascal] New Dispose and FreeMem and objects

2011-08-26 Thread Jonas Maebe
On 26 Aug 2011, at 22:39, Andrew Haines wrote: Maybe Dispose can call a destructor and that is the difference between Dispose and FreeMem? The other difference is that dispose() will finalize any reference counted fields, while freemem won't.

Re: [fpc-pascal] New Dispose and FreeMem and objects

2011-08-26 Thread Andrew Haines
On 08/26/11 17:14, Jonas Maebe wrote: On 26 Aug 2011, at 22:39, Andrew Haines wrote: Maybe Dispose can call a destructor and that is the difference between Dispose and FreeMem? The other difference is that dispose() will finalize any reference counted fields, while freemem won't.

Re: [fpc-pascal] New Dispose and FreeMem and objects

2011-08-26 Thread Jonas Maebe
On 27 Aug 2011, at 00:18, Andrew Haines wrote: Ok so freemem is okay as long as I am careful about the members of the object. There may be other problems I'm not thinking of right now. I don't understand why you want to use freemem for objects, since the only difference with dispose is that