1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
{
**********************************************************************
This file is part of LazUtils.
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
**********************************************************************
}
unit LazDbgLog;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
function MemSizeString(const s: string): PtrUInt;
function MemSizeFPList(const List: TFPList): PtrUInt;
function GetStringRefCount(const s: string): PtrInt;
implementation
function MemSizeString(const s: string): PtrUInt;
begin
Result:=length(s);
if s<>'' then
inc(Result,SizeOf(Pointer)*4);
end;
function MemSizeFPList(const List: TFPList): PtrUInt;
begin
if List=nil then exit(0);
Result:=PtrUInt(List.InstanceSize)
+PtrUInt(List.Capacity)*SizeOf(Pointer);
end;
function GetStringRefCount(const s: string): PtrInt;
begin
if s='' then
Result:=-1
else
Result:=PPtrInt(s)[-2];
end;
end.
|