[fpc-devel] an observation about GetMem

Peter Vreman peter at freepascal.org
Mon Sep 8 10:42:41 CEST 2008


> On Sat, Sep 06, 2008 at 11:25:19AM +0100, Jonas Maebe wrote:
>>
>> On 05 Sep 2008, at 17:25, Peter Popov wrote:
>>
>> >>In FPC it is done by design. If 0 bytes are asked we allocate at
>> >>least the minimum alignment to
>> >>get a valid pointer. This is done for compatibility with TP7.0 that
>> >>returns the value of heapptr
>> >>which is also a valid pointer.
>> >
>> >Thanks for the clarification!
>> >I guess if you switch to reallocmem entirely, there will be delphi
>> >compatibility, yes?
>>
>> reallocmem indeed frees the memory and sets the pointer to nil if you
>> specify "0" as the memory size.
>
> Look at thread "AllocMem(0)<>nil" at 25.03.08. I had the same problem.

AllocMem uses internally the same memory allocation as GetMem. So the behaviour of FPC is by design.

Peter





More information about the fpc-devel mailing list