anchor.diff:  
       // Wait for thread
       err := WaitForThreadTerminate(TID, 2000);
  +    CloseThread(TID);
   
       // Free resources
  -    if free_data = 1 then tml_Sys_Free(thread_def);
  +    if free_data = 1 then
  +       tml_Sys_Free(thread_def);
   
       if err = 0 then Result := 1
                  else Result := 0;
  
positive.code: 
    //Finally we run the thread function
    Result := ptrint(ThreadData.Func(ThreadData.Data));
  end;
  
  { FPC specific thread create function to replace Vortex's thread create.
  
negative.code:     ThreadData^.Func := func;
      ThreadData^.Data := user_data;
  
      // Start thread suspended
      TThreadID(thread_def^) := BeginThread(@C2P_Translator, ThreadData);
  
      if TThreadID(thread_def^) > 0 then
      begin
        // Don't free memory here, it will be done in the thread function
        Result := 1;
      end
      else
      begin
        // Free memory
        dispose(ThreadData);
        Result := 0;
      end;
    end
    else Result := 0;
  