Browse Source

Amiga: System CloseList() and CleanupThreadProcChain() are called after the memory manager is already shut down changed to native os memory allocation

Marcus Sackrow 2 years ago
parent
commit
ac93ad48e3
2 changed files with 11 additions and 7 deletions
  1. 7 5
      rtl/amicommon/sysfile.inc
  2. 4 2
      rtl/amicommon/sysos.inc

+ 7 - 5
rtl/amicommon/sysfile.inc

@@ -57,7 +57,7 @@ begin
   while l<>nil do begin
     tmpNext:=l;
     l:=l^.next;
-    dispose(tmpNext);
+    FreePooled(ASYS_heapPool, tmpNext, SizeOf(TFileList));
   end;
   ReleaseSemaphore(ASYS_fileSemaphore);
 end;
@@ -80,13 +80,15 @@ begin
                            else p:=p^.next;
     p:=nil;
   end else begin
-    { if the list is not yet allocated, allocate it. }
-    New(l);
+    { if the list is not yet allocated, allocate it.
+      the FileList is only freed after the memory manager has shut
+      down, therefore native OS allocation }
+    l := AllocPooled(ASYS_heapPool,sizeof(TFileList));
     l^.next:=nil;
   end;
 
   if not inList then begin
-    New(p);
+    P := AllocPooled(ASYS_heapPool,sizeof(TFileList));
     p^.handle:=h;
     p^.buffered:=False;
     p^.next:=l^.next;
@@ -121,7 +123,7 @@ begin
 
   if inList then begin
     tmpList:=p^.next^.next;
-    dispose(p^.next);
+    FreePooled(ASYS_heapPool, p^.next, SizeOf(TFileList));
     p^.next:=tmpList;
   end
 {$IFDEF ASYS_FPC_FILEDEBUG}

+ 4 - 2
rtl/amicommon/sysos.inc

@@ -211,7 +211,9 @@ Procedure AddThreadProc(var procList: PThreadProcInfo; Proc: TProcedure);
 var
   P : PThreadProcInfo;
 Begin
-  New(P);
+  // the ThreadProc chain is only freed after the memory manager has
+  // shut down, therefore native OS allocation
+  P := AllocPooled(ASYS_heapPool,sizeof(TThreadProcInfo));
   P^.Next:=procList;
   P^.Proc:=Proc;
   procList:=P;
@@ -225,7 +227,7 @@ Begin
     begin
       p:=procList;
       procList:=procList^.next;
-      dispose(p);
+      FreePooled(ASYS_heapPool,P,sizeof(TThreadProcInfo));
     end;
 End;