mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-16 15:38:15 +02:00
parent
3e054f46c3
commit
d337c3ca6a
@ -1313,4 +1313,26 @@ begin
|
|||||||
fillchar(internal_status,sizeof(internal_status),0);
|
fillchar(internal_status,sizeof(internal_status),0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure FinalizeHeap;
|
||||||
|
var
|
||||||
|
poc : poschunk;
|
||||||
|
i : longint;
|
||||||
|
begin
|
||||||
|
{$ifdef HAS_SYSOSFREE}
|
||||||
|
for i:=low(freelists_free_chunk) to high(freelists_free_chunk) do
|
||||||
|
if freelists_free_chunk[i] then
|
||||||
|
SysOSFree(freelists_fixed[i]^.poc,freelists_fixed[i]^.poc^.size);
|
||||||
|
while assigned(freeoslist) do
|
||||||
|
begin
|
||||||
|
poc:=freeoslist^.next;
|
||||||
|
SysOSFree(freeoslist, freeoslist^.size);
|
||||||
|
dec(freeoslistcount);
|
||||||
|
freeoslist:=poc;
|
||||||
|
end;
|
||||||
|
{$endif HAS_SYSOSFREE}
|
||||||
|
{ release mutex }
|
||||||
|
MemoryMutexManager.MutexDone;
|
||||||
|
end;
|
||||||
|
|
||||||
{$endif HAS_MEMORYMANAGER}
|
{$endif HAS_MEMORYMANAGER}
|
||||||
|
@ -663,10 +663,12 @@ end;
|
|||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
Procedure system_exit;forward;
|
Procedure system_exit;forward;
|
||||||
|
Procedure FinalizeHeap;forward;
|
||||||
|
|
||||||
Procedure InternalExit;
|
Procedure InternalExit;
|
||||||
var
|
var
|
||||||
current_exit : Procedure;
|
current_exit : Procedure;
|
||||||
|
i : longint;
|
||||||
Begin
|
Begin
|
||||||
while exitProc<>nil Do
|
while exitProc<>nil Do
|
||||||
Begin
|
Begin
|
||||||
@ -691,6 +693,12 @@ Begin
|
|||||||
Flush(ErrOutput);
|
Flush(ErrOutput);
|
||||||
Flush(StdOut);
|
Flush(StdOut);
|
||||||
Flush(StdErr);
|
Flush(StdErr);
|
||||||
|
{ finally release the heap if possible, especially
|
||||||
|
important for DLLs }
|
||||||
|
for i:=0 to argc do
|
||||||
|
sysfreemem(argv[i]);
|
||||||
|
sysfreemem(argv);
|
||||||
|
FinalizeHeap;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,7 +377,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
Close(stderr);
|
Close(stderr);
|
||||||
Close(stdout);
|
Close(stdout);
|
||||||
|
Close(erroutput);
|
||||||
|
Close(Input);
|
||||||
|
Close(Output);
|
||||||
{ what about Input and Output ?? PM }
|
{ what about Input and Output ?? PM }
|
||||||
|
{ now handled, FPK }
|
||||||
end;
|
end;
|
||||||
remove_exception_handlers;
|
remove_exception_handlers;
|
||||||
|
|
||||||
@ -466,7 +470,7 @@ var
|
|||||||
end;
|
end;
|
||||||
DLL_THREAD_ATTACH :
|
DLL_THREAD_ATTACH :
|
||||||
begin
|
begin
|
||||||
inc(Thread_count);
|
inclocked(Thread_count);
|
||||||
{$warning Allocate Threadvars !}
|
{$warning Allocate Threadvars !}
|
||||||
if assigned(Dll_Thread_Attach_Hook) then
|
if assigned(Dll_Thread_Attach_Hook) then
|
||||||
Dll_Thread_Attach_Hook(DllParam);
|
Dll_Thread_Attach_Hook(DllParam);
|
||||||
@ -474,7 +478,7 @@ var
|
|||||||
end;
|
end;
|
||||||
DLL_THREAD_DETACH :
|
DLL_THREAD_DETACH :
|
||||||
begin
|
begin
|
||||||
dec(Thread_count);
|
declocked(Thread_count);
|
||||||
if assigned(Dll_Thread_Detach_Hook) then
|
if assigned(Dll_Thread_Detach_Hook) then
|
||||||
Dll_Thread_Detach_Hook(DllParam);
|
Dll_Thread_Detach_Hook(DllParam);
|
||||||
{$warning Release Threadvars !}
|
{$warning Release Threadvars !}
|
||||||
@ -484,9 +488,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Dll_entry:=true; { return value is ignored }
|
Dll_entry:=true; { return value is ignored }
|
||||||
If SetJmp(DLLBuf) = 0 then
|
If SetJmp(DLLBuf) = 0 then
|
||||||
begin
|
FPC_Do_Exit;
|
||||||
FPC_DO_EXIT;
|
|
||||||
end;
|
|
||||||
if assigned(Dll_Process_Detach_Hook) then
|
if assigned(Dll_Process_Detach_Hook) then
|
||||||
Dll_Process_Detach_Hook(DllParam);
|
Dll_Process_Detach_Hook(DllParam);
|
||||||
end;
|
end;
|
||||||
@ -1237,5 +1239,5 @@ begin
|
|||||||
errno:=0;
|
errno:=0;
|
||||||
initvariantmanager;
|
initvariantmanager;
|
||||||
initwidestringmanager;
|
initwidestringmanager;
|
||||||
InitWin32Widestrings
|
InitWin32Widestrings;
|
||||||
end.
|
end.
|
||||||
|
@ -458,7 +458,7 @@ var
|
|||||||
end;
|
end;
|
||||||
DLL_THREAD_ATTACH :
|
DLL_THREAD_ATTACH :
|
||||||
begin
|
begin
|
||||||
inc(Thread_count);
|
inclocked(Thread_count);
|
||||||
{$warning Allocate Threadvars !}
|
{$warning Allocate Threadvars !}
|
||||||
if assigned(Dll_Thread_Attach_Hook) then
|
if assigned(Dll_Thread_Attach_Hook) then
|
||||||
Dll_Thread_Attach_Hook(DllParam);
|
Dll_Thread_Attach_Hook(DllParam);
|
||||||
@ -466,7 +466,7 @@ var
|
|||||||
end;
|
end;
|
||||||
DLL_THREAD_DETACH :
|
DLL_THREAD_DETACH :
|
||||||
begin
|
begin
|
||||||
dec(Thread_count);
|
declocked(Thread_count);
|
||||||
if assigned(Dll_Thread_Detach_Hook) then
|
if assigned(Dll_Thread_Detach_Hook) then
|
||||||
Dll_Thread_Detach_Hook(DllParam);
|
Dll_Thread_Detach_Hook(DllParam);
|
||||||
{$warning Release Threadvars !}
|
{$warning Release Threadvars !}
|
||||||
|
@ -814,10 +814,13 @@ begin
|
|||||||
if IsLibrary then
|
if IsLibrary then
|
||||||
exit;
|
exit;
|
||||||
// ExitDLL(ExitCode);
|
// ExitDLL(ExitCode);
|
||||||
if not IsConsole then begin
|
if not IsConsole then
|
||||||
|
begin
|
||||||
Close(stderr);
|
Close(stderr);
|
||||||
Close(stdout);
|
Close(stdout);
|
||||||
{ what about Input and Output ?? PM }
|
Close(erroutput);
|
||||||
|
Close(Input);
|
||||||
|
Close(Output);
|
||||||
end;
|
end;
|
||||||
ExitThread(exitcode);
|
ExitThread(exitcode);
|
||||||
end;
|
end;
|
||||||
@ -859,21 +862,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
DLL_THREAD_ATTACH :
|
DLL_THREAD_ATTACH :
|
||||||
begin
|
begin
|
||||||
inc(Thread_count);
|
inclocked(Thread_count);
|
||||||
{$warning Allocate Threadvars !}
|
{$warning Allocate Threadvars !}
|
||||||
if assigned(Dll_Thread_Attach_Hook) then
|
if assigned(Dll_Thread_Attach_Hook) then
|
||||||
Dll_Thread_Attach_Hook(DllParam);
|
Dll_Thread_Attach_Hook(DllParam);
|
||||||
end;
|
end;
|
||||||
DLL_THREAD_DETACH :
|
DLL_THREAD_DETACH :
|
||||||
begin
|
begin
|
||||||
dec(Thread_count);
|
declocked(Thread_count);
|
||||||
if assigned(Dll_Thread_Detach_Hook) then
|
if assigned(Dll_Thread_Detach_Hook) then
|
||||||
Dll_Thread_Detach_Hook(DllParam);
|
Dll_Thread_Detach_Hook(DllParam);
|
||||||
{$warning Release Threadvars !}
|
{$warning Release Threadvars !}
|
||||||
end;
|
end;
|
||||||
DLL_PROCESS_DETACH :
|
DLL_PROCESS_DETACH :
|
||||||
begin
|
begin
|
||||||
FPC_DO_EXIT;
|
FPC_Do_Exit;
|
||||||
if assigned(Dll_Process_Detach_Hook) then
|
if assigned(Dll_Process_Detach_Hook) then
|
||||||
Dll_Process_Detach_Hook(DllParam);
|
Dll_Process_Detach_Hook(DllParam);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user