Browse Source

+ RelocateHeap: tolerate being called more than once.

git-svn-id: trunk@17762 -
sergei 14 years ago
parent
commit
3e145f6d77
1 changed files with 3 additions and 1 deletions
  1. 3 1
      rtl/inc/heap.inc

+ 3 - 1
rtl/inc/heap.inc

@@ -1507,11 +1507,13 @@ var
   loc_freelists: pfreelists;
   loc_freelists: pfreelists;
 begin
 begin
   { this function should be called in main thread context }
   { this function should be called in main thread context }
-  loc_freelists := @freelists;
 {$ifdef FPC_HAS_FEATURE_THREADING}
 {$ifdef FPC_HAS_FEATURE_THREADING}
+  if heap_lock_use > 0 then
+    exit;
   heap_lock_use := 1;
   heap_lock_use := 1;
   initcriticalsection(heap_lock);
   initcriticalsection(heap_lock);
 {$endif}
 {$endif}
+  loc_freelists := @freelists;
   { loc_freelists still points to main thread's freelists, but they
   { loc_freelists still points to main thread's freelists, but they
     have a reference to the global main freelists, fix them to point
     have a reference to the global main freelists, fix them to point
     to the main thread specific variable }
     to the main thread specific variable }