Mattias Gaertner wrote:
On Wed, 30 Apr 2008 01:22:47 +0200
Marc Weustink <[EMAIL PROTECTED]> wrote:
Alan Krause wrote:
Hans MÃ¥rtensson wrote:
But that would not work after the pointer was used and then it's
memory freed.
So a better way might be:
Always when declaring pointers do it this way:
var p: ^sometype = nil;
Then in stead of using the freemem, define your own procedure:
procedure myfreemem(var p: pointer);
begin if p<>nil then begin freemem(p); p:=nil end end;
Use FreeAndNil() -
http://www.delphibasics.co.uk/RTL.asp?Name=FreeAndNil
FreeAndNil works only for classes, not for objects/record
ReAllocMem(p,0);
Ah, now I understand why you use them :)
Anyway does it set p:=nil ?
Marc
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal