[fpc-pascal] Pointers in Pascal!!
    Alan Krause 
    alank at shermanloan.com
       
    Tue Apr 29 20:37:30 CEST 2008
    
    
  
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
Alan Krause
    
    
More information about the fpc-pascal
mailing list