Allow MemSize(nil) to match FreeMem(nil).

This commit is contained in:
Rika Ichinose 2024-10-27 21:49:05 +03:00
parent c08d73054a
commit ba7a76bf37
2 changed files with 4 additions and 0 deletions

View File

@ -1303,6 +1303,8 @@ end;
function SysMemSize(p: pointer): ptruint;
begin
if not assigned(p) then
exit(0);
result := pmemchunk_fixed(pointer(p)-sizeof(tmemchunk_fixed_hdr))^.size;
if (result and fixedsizeflag) = 0 then
result := result and sizemask-sizeof(tmemchunk_var_hdr)

View File

@ -782,6 +782,8 @@ function TraceMemSize(p:pointer):ptruint;
var
pp : pheap_mem_info;
begin
if not assigned(p) then
exit(0);
pp:=pheap_mem_info(p-sizeof(theap_mem_info));
TraceMemSize:=pp^.size;
end;