* WebAssembly threads: use New and Dispose instead of GetMem/FreeMem for allocating/freeing TWasmThread

This commit is contained in:
Nikolay Nikolov 2024-08-07 16:46:13 +03:00
parent f23cc9ec6d
commit 77d592221a

View File

@ -371,7 +371,7 @@ Var
begin
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('WasiBeginThread(sa: '+IntToStr(PtrUint(Sa))+',ss: '+IntToStr(PtrUint(StackSize))+',TF: '+IntToStr(PtrUint(ThreadFunction))+',Arg: '+IntToStr(PtrUint(P))+',fl: '+IntToStr(PtrUint(CreationFlags))+',ID: '+IntToStr(PtrUint(ThreadID))+')');{$ENDIF}
T:=GetMem(SizeOf(TWasmThread));
New(T);
T^.StackBlock:=nil;
T^.TLSBlock:=nil;
ThreadID:=T;
@ -403,7 +403,7 @@ begin
FreeMem(T^.StackBlock);
if Assigned(T^.TLSBlock) then
FreeMem(T^.TLSBlock);
FreeMem(T);
Dispose(T);
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('WasiBeginThread: spawn thread failed, freeing thread struct');{$ENDIF}
WasiBeginThread:=TThreadID(0);
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('WasiBeginThread: spawn thread failed, returning 0');{$ENDIF}