mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 03:09:11 +02:00
Handle change of memory base address after call to SysTryResizeMem
git-svn-id: trunk@43062 -
This commit is contained in:
parent
85616e7dc7
commit
ee22dbe589
@ -823,7 +823,7 @@ var
|
|||||||
i, allocsize,
|
i, allocsize,
|
||||||
movesize : ptruint;
|
movesize : ptruint;
|
||||||
pl : pdword;
|
pl : pdword;
|
||||||
pp : pheap_mem_info;
|
pp,prevpp{$ifdef EXTRA},ppv{$endif} : pheap_mem_info;
|
||||||
oldsize,
|
oldsize,
|
||||||
oldextrasize,
|
oldextrasize,
|
||||||
oldexactsize : ptruint;
|
oldexactsize : ptruint;
|
||||||
@ -885,6 +885,7 @@ begin
|
|||||||
inc(allocsize,tail_size);
|
inc(allocsize,tail_size);
|
||||||
{ Try to resize the block, if not possible we need to do a
|
{ Try to resize the block, if not possible we need to do a
|
||||||
getmem, move data, freemem }
|
getmem, move data, freemem }
|
||||||
|
prevpp:=pp;
|
||||||
if not SysTryResizeMem(pp,allocsize) then
|
if not SysTryResizeMem(pp,allocsize) then
|
||||||
begin
|
begin
|
||||||
{ get a new block }
|
{ get a new block }
|
||||||
@ -905,6 +906,45 @@ begin
|
|||||||
p:=newp;
|
p:=newp;
|
||||||
traceReAllocMem := newp;
|
traceReAllocMem := newp;
|
||||||
exit;
|
exit;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if (pp<>prevpp) then
|
||||||
|
begin
|
||||||
|
{ We need to update the previous/next chains }
|
||||||
|
if assigned(pp^.previous) then
|
||||||
|
pp^.previous^.next:=pp;
|
||||||
|
if assigned(pp^.next) then
|
||||||
|
pp^.next^.previous:=pp;
|
||||||
|
if prevpp=loc_info^.heap_mem_root then
|
||||||
|
loc_info^.heap_mem_root:=pp;
|
||||||
|
{$ifdef EXTRA}
|
||||||
|
{ remove prevpp from prev_valid chain }
|
||||||
|
ppv:=loc_info^.heap_valid_last;
|
||||||
|
if (ppv=prevpp) then
|
||||||
|
loc_info^.heap_valid_last:=pp^.prev_valid
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
while assigned(ppv) do
|
||||||
|
begin
|
||||||
|
if (ppv^.prev_valid=prevpp) then
|
||||||
|
begin
|
||||||
|
ppv^.prev_valid:=pp^.prev_valid;
|
||||||
|
if prevpp=loc_info^.heap_valid_first then
|
||||||
|
loc_info^.heap_valid_first:=ppv;
|
||||||
|
ppv:=nil;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ppv:=ppv^.prev_valid;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{ Reinsert new value in last position }
|
||||||
|
pp^.prev_valid:=loc_info^.heap_valid_last;
|
||||||
|
loc_info^.heap_valid_last:=pp;
|
||||||
|
if not assigned(loc_info^.heap_valid_first) then
|
||||||
|
loc_info^.heap_valid_first:=pp;
|
||||||
|
{$endif EXTRA}
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{ Recreate the info block }
|
{ Recreate the info block }
|
||||||
pp^.sig:=longword(AllocateSig);
|
pp^.sig:=longword(AllocateSig);
|
||||||
|
Loading…
Reference in New Issue
Block a user