浏览代码

Move update of fields counting allocated memory to after SysGetMem call

git-svn-id: trunk@41882 -
pierre 6 年之前
父节点
当前提交
7b3e027dc8
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      rtl/inc/heaptrc.pp

+ 4 - 2
rtl/inc/heaptrc.pp

@@ -509,8 +509,6 @@ var
 begin
   loc_info := @heap_info;
   try_finish_heap_free_todo_list(loc_info);
-  inc(loc_info^.getmem_size,size);
-  inc(loc_info^.getmem8_size,(size+7) and not 7);
 { Do the real GetMem, but alloc also for the info block }
 {$ifdef cpuarm}
   allocsize:=(size + 3) and not 3+sizeof(theap_mem_info)+extra_info_size;
@@ -529,6 +527,10 @@ begin
     end;
   pp:=pheap_mem_info(p);
   inc(p,sizeof(theap_mem_info));
+  { Update getmem_size and getmem8_size only after successful call 
+    to SysGetMem }
+  inc(loc_info^.getmem_size,size);
+  inc(loc_info^.getmem8_size,(size+7) and not 7);
 { Create the info block }
   pp^.sig:=longword(AllocateSig);
   pp^.todolist:=@loc_info^.heap_free_todo;