[fpc-devel] AllocMem(0)<>nil

Peter Vreman peter at freepascal.org
Tue Mar 25 18:30:13 CET 2008


> Hi.
>
> I discovered some Delphi incompatibility. Call AllocMem(0) do not return nil.
> Fpc from svn.
>
> In SysGetMem are some comments about it:
>
>   if size=0 then
>     { we always need to allocate something, using heapend is not possible,
>       because heappend can be changed by growheap (PFV) }
>     size := 1;
>
> Is this behaviour essential, or is possible make it compatible with
> Delphi?

Current behaviour is compatible with TP7 that gave a valid pointer back pointing to heapend. See
also the comment.

IMHO doing an AllocMem(0) is an error in your program.

Peter




More information about the fpc-devel mailing list