[fpc-pascal] Does ReallocMem(p,0) always set p to nil?
    Michael Van Canneyt 
    michael.vancanneyt at wisa.be
       
    Mon May  7 09:22:46 CEST 2007
    
    
  
On Mon, 7 May 2007, Vincent Snijders wrote:
> Vincent Snijders schreef:
> > Hi,
> > 
> > Consider this piece of code:
> > 
> > var
> >   p: pointer;
> > begin
> >   p := getmem(100);
> >   reallocmem(p,0);
> >   p := nil;
> > end.
> > 
> > Do I need to do p:=nil, if I want to be sure that p contains nil?
> > 
> > I saw that both system.SysReAllocMem and cmem.CReAllocMem do this, is
> > size=0, but the docs at
> > http://lazarus-ccr.sourceforge.net/docs/rtl/system/reallocmem.html don't
> > mention this, so I don't know if I can be trust that is the case for always
> > for all memory managers.
> 
> Tough question apparently. Let's try to word it differently.
> 
> After reallocmem(p,0) I observed that p is always nil. Is this an
> implementation detail (subject to change) or part of the specification of
> reallocmem?
This is part of the specification.
Michael.
    
    
More information about the fpc-pascal
mailing list