[fpc-devel] cmem not aligning memory

C Western l at c-m-w.me.uk
Thu Apr 8 22:48:54 CEST 2010


On 08/04/10 14:12, Jonas Maebe wrote:
>
> On 08 Apr 2010, at 15:05, C Western wrote:
>
>> How about an alternative implementation, without the integer recording
>> size? I had a quick try at this - the only use of the MemSize routine
>> in fpc+lazarus seems to be in an optimization in resizing strings. If
>> this routine is adjusted to cope with MemSize returning 0 to indicate
>> "not known" then most applications should work.
>
> Having "most" applications work is a great recipe for annoying bug
> reports (and annoyed users).

True, except that the current implementation has its own problems, as 
discussed. Fortunately I don't see any need to use cmem for my own 
application; I think I added it at some point because there was some 
indication it was faster, but a quick test now suggests not.

>
>> This implementation as the additional advantage that mixing malloc and
>> free's between C and Pascal then work.
>
> That would indeed be nice, but I don't think it is feasible. Someone who
> values such functionality more than a full implementation of the memory
> manager can always install their own memory manager.
>
>> PS: The CFreeMemSize seems to be incorrectly implemented - it does not
>> offset the pointer.
>
> It calls CFreeMem, which does perform the adjustment.

Sorry - you are quite right.

Colin



More information about the fpc-devel mailing list