On 01 Mar 2011, at 15:25, Sergei Gorelkin wrote:

> Jonas Maebe пишет:
>> a) give a run time error if someone tries to do freemem(nil)
> 
> Delphi allows freemem(nil) without error, consistent with TObject.Free

I don't think TObject.Free and freemem are really comparable. TObject.Free is 
much more high level.

> I remember a discussion some time ago, the conclusion was it's compatible 
> with TP
> rather than with Delphi.

TP also returns nil for getmem(0) (and allows freemem(nil,0) -- TP doesn't have 
a freemem() function without a separate "size" parameter).

I guess it's one of the ways in which the FPC version was intended to be 
cleaner than the TP and Delphi versions of the same functions (and since 
they're RTL functions, they cannot simply be changed based on the compilation 
mode of the current unit). Since it's also consistent with how other memory 
allocators work (e.g., the libc ones), I don't think that was a bad decision.

>> If it is changed, it will also require changes in cmem (and probably also in 
>> heaptrc), because at least on Mac OS X libc also returns a valid pointer for 
>> malloc(0).
> Not necessary, if we have only one GetMem function

It's true, that way it could also be changed.


Jonas_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to