On Thu, 15 Oct 2009, Graeme Geldenhuys wrote:
On 15/10/2009, Graeme Geldenhuys <graemeg.li...@gmail.com> wrote:
------------------------
function AllocateMemory( const Size: longint ): pointer;
procedure DeallocateMemory( Var P: pointer );
OK, I managed to convert those two functions to the following.. it now
compiles under my 64bit FPC.
-----------------------------
function AllocateMemory( const Size: ValUInt ): pointer;
begin
GetMem( Result, size + sizeof( Size ) );
PtrUInt(Result^) := Size;
inc( Result, sizeof( Size ) );
end;
procedure DeallocateMemory( Var P: pointer );
var
Size: ValUInt;
begin
if P = nil then
exit;
dec( P, sizeof( size ) );
Size := ValUInt(P^);
FreeMem( P, Size + sizeof( Size ) );
P := nil;
end;
-----------------------------
But based on Florian's reply, I assume I don't need to bother using
these methods, because FreeMem() will automatically know much much
memory to deallocate.
Yes.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal