diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2010-01-04 22:13:43 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2010-01-04 22:13:43 +0100 |
| commit | be965b1ba6d05d188ccf4eb5b9f93ca56209161c (patch) | |
| tree | df5d87331e277be31551f23806a795ef31eb3a7e | |
| parent | bd94bf0ea362376243e98ed509fbe8c5028ff4b2 (diff) | |
| download | tuxcmd-be965b1ba6d05d188ccf4eb5b9f93ca56209161c.tar.xz | |
Search: items allocation cleanup
| -rw-r--r-- | USearch.pas | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/USearch.pas b/USearch.pas index 6e8f362..732bcdb 100644 --- a/USearch.pas +++ b/USearch.pas @@ -911,7 +911,7 @@ begin try if CancelIt then Exit; if Length(StartDir) < 1 then StartDir := '/'; - DebugMsg(['++ Entering directory ', StartDir]); +// DebugMsg(['++ Entering directory ', StartDir]); GUIMutex.Acquire; CurrentDir := StartDir; @@ -969,20 +969,20 @@ begin // Add the record to the list if Matches then begin GUIMutex.Acquire; - FList.Add(LocalList[i]); - libc_free(Data^.FDisplayName); - PDataItem(LocalList[i])^.FDisplayName := strdup(PChar(StartDir + FileName)); - if Assigned(PDataItem(LocalList[i])^.LnkPointTo) then begin - libc_free(PDataItem(LocalList[i])^.LnkPointTo); - PDataItem(LocalList[i])^.LnkPointTo := nil; + FList.Add(DuplicateDataItem(Data)); + libc_free(PDataItem(FList[FList.Count - 1])^.FDisplayName); + PDataItem(FList[FList.Count - 1])^.FDisplayName := g_strdup(PChar(StartDir + FileName)); + if Assigned(PDataItem(FList[FList.Count - 1])^.LnkPointTo) then begin + libc_free(PDataItem(FList[FList.Count - 1])^.LnkPointTo); + PDataItem(FList[FList.Count - 1])^.LnkPointTo := nil; end; - if (FEngine is TVFSEngine) and (FRootEngine <> FEngine) - then PDataItem(LocalList[i])^.LnkPointTo := strdup(PChar((FEngine as TVFSEngine).SavePath)); + if (FEngine is TVFSEngine) and (FRootEngine <> FEngine) then + PDataItem(FList[FList.Count - 1])^.LnkPointTo := g_strdup(PChar((FEngine as TVFSEngine).SavePath)); GUIMutex.Release; end; - if Data^.IsDir and ((not FDontLeaveFS) or (FDontLeaveFS and FEngine.IsOnSameFS(FStartPath, StartDir + FileName, True))) - then DoRecurse(IncludeTrailingPathDelimiter(StartDir) + FileName); + if Data^.IsDir and ((not FDontLeaveFS) or (FDontLeaveFS and FEngine.IsOnSameFS(FStartPath, StartDir + FileName, True))) then + DoRecurse(IncludeTrailingPathDelimiter(StartDir) + FileName); // Handle archives if (not Data^.IsDir) and FSearchArchives and (not (FEngine is TVFSEngine)) then begin @@ -1002,8 +1002,7 @@ begin end; end; - if not Matches then - FreeDataItem(PDataItem(LocalList[i])); + FreeDataItem(PDataItem(LocalList[i])); end; end; LocalList.Free; @@ -1038,16 +1037,14 @@ begin Inc(Pos); if Pos > Length(FStringFind) then begin Result := True; - FEngine.CloseFile(fd, nil); - libc_free(Buffer); - Exit; + Break; end; end else Pos := 1; end; // DebugMsg(['Read : ', Read, ' bytes.']); if CancelIt then Break; - until Read < BlockSize; + until (Read < BlockSize) or Result; FEngine.CloseFile(fd, nil); libc_free(Buffer); except |
