+ optimization in SysTinyReAllocMem for the case of shrinking a memory block

git-svn-id: trunk@28714 -
This commit is contained in:
nickysn 2014-09-23 01:29:53 +00:00
parent a0d03d5f33
commit e4f3f33692

View File

@ -288,6 +288,12 @@
if size > oldsize then
FillChar((TTinyHeapPointerArithmeticType(p)+oldsize)^, size-oldsize, 0);
end
else if OldAllocSize > NewAllocSize then
begin
{ we're decreasing the memory block size, so we can just free the remaining memory at the end }
PTinyHeapMemBlockSize(p)[-1] := size;
InternalTinyFreeMem(Pointer(TTinyHeapPointerArithmeticType(p)+(NewAllocSize-PtrUInt(SizeOf(TTinyHeapMemBlockSize)))), OldAllocSize-NewAllocSize);
end
else
begin
result := AllocMem(size);