From f02993636a68e2a611acf6c4519cf6f139ab4737 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 4 Oct 2009 21:22:09 +0200 Subject: Force use glibc malloc() and free() for plugin-related allocations on PPC FreePascal sucks ass on PowerPC!! --- vfs/UVFSCore.pas | 98 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'vfs') diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index 45bfc83..ae752c8 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -182,7 +182,7 @@ const ConstGlobalModulePath1 = '/usr/lib/tuxcmd'; var BinaryPath: string; -procedure VFSLogFunc(s: PChar); cdecl; +procedure VFSLogFunc(const s: PChar); cdecl; begin DebugMsg([' ### VFS ###: ', s]); end; @@ -244,14 +244,14 @@ begin s := FVFSGetExts; if s <> nil then begin ParseString(String(s), ';', Extensions); - libc_free(s); + real_libc_free(s); end; end; if @FVFSGetServices <> nil then begin s := FVFSGetServices; if s <> nil then begin ParseString(String(s), ';', Services); - libc_free(s); + real_libc_free(s); end; end; end; @@ -274,10 +274,10 @@ end; procedure _free_PVFSInfo(Info: PVFSInfo); begin if Info <> nil then begin - if Info^.Name <> nil then libc_free(Info^.Name); - if Info^.ID <> nil then libc_free(Info^.ID); - if Info^.About <> nil then libc_free(Info^.About); - if Info^.Copyright <> nil then libc_free(Info^.Copyright); + if Info^.Name <> nil then real_libc_free(Info^.Name); + if Info^.ID <> nil then real_libc_free(Info^.ID); + if Info^.About <> nil then real_libc_free(Info^.About); + if Info^.Copyright <> nil then real_libc_free(Info^.Copyright); end; end; @@ -392,7 +392,7 @@ begin Result := 0; try if @FSourcePlugin.FVFSListFirst = nil then Exit; - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); // DebugMsg(['Item = ', Int64(P)]); // DebugMsg(['FVFSListFirst']); @@ -401,7 +401,7 @@ begin FSourcePlugin.FVFSListClose(FGlobs); if Res = cVFS_Not_More_Files then Result := 0 else Result := Res; - libc_free(P); + real_libc_free(P); Exit; end; @@ -453,12 +453,12 @@ begin DebugMsg(['^^VFS (EE): GetListing: Item-Exception: ', E.Message]); end; end; // of if AddDotFiles - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); // Not needed - just zero-erase the memory + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); // Not needed - just zero-erase the memory // DebugMsg(['Checkpoint 13']); - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); // DebugMsg(['Item = ', Int64(P)]); // DebugMsg(['Checkpoint 14']); @@ -469,7 +469,7 @@ begin until (Res <> cVFS_OK) or (BreakProcessingKind = 2); if BreakProcessingKind <> 0 then DebugMsg(['^^VFS (WW): GetListing: stopped by BreakProcessing']); - libc_free(P); + real_libc_free(P); FSourcePlugin.FVFSListClose(FGlobs); if Res <> cVFS_Not_More_Files then Result := Res; except @@ -543,7 +543,7 @@ begin s := FSourcePlugin.FVFSGetPrefix(FGlobs); if s <> nil then begin Result := String(s); - libc_free(s); + real_libc_free(s); end; end; end; @@ -556,7 +556,7 @@ begin s := FSourcePlugin.FVFSGetPath(FGlobs); if s <> nil then begin Result := String(s); - libc_free(s); + real_libc_free(s); end; end; end; @@ -569,7 +569,7 @@ begin s := FSourcePlugin.FVFSGetPathURI(FGlobs); if s <> nil then begin Result := String(s); - libc_free(s); + real_libc_free(s); end; end; end; @@ -617,11 +617,11 @@ begin if @FSourcePlugin.FVFSFileExists <> nil then begin Result := FSourcePlugin.FVFSFileExists(FGlobs, PChar(FileName), Use_lstat); if Result and (@FSourcePlugin.FVFSFileInfo <> nil) then begin - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), P); if (Res <> cVFS_OK) or (P = nil) or (TVFSItemType(P^.ItemType) <> vDirectory) then Result := False; - libc_free(P); + real_libc_free(P); end; end else Result := False; end; @@ -633,7 +633,7 @@ var P: PVFSItem; begin Result := nil; if @FSourcePlugin.FVFSFileInfo = nil then Exit; - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); @@ -670,10 +670,10 @@ begin GID := P^.iGID; Size := P^.iSize; PackedSize := P^.iPackedSize; - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); end; Result := Item; except @@ -748,15 +748,15 @@ begin LocalList := TStringList.Create; try try - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); if Res <> cVFS_OK then DebugMsg(['*** FillDirFiles - VFSFileInfo(', APath, ') failed. Code = ', Res]); AddEntry(APath, True, True); - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); APath := IncludeTrailingPathDelimiter(APath); if @FSourcePlugin.FVFSChangeDir <> nil then Res := FSourcePlugin.FVFSChangeDir(FGlobs, PChar(APath)) @@ -764,15 +764,15 @@ begin if Res <> 0 then Exit; if @FSourcePlugin.FVFSListFirst = nil then Exit; - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), P); if Res <> cVFS_OK then begin FSourcePlugin.FVFSListClose(FGlobs); - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); Exit; end; @@ -780,19 +780,19 @@ begin if TVFSItemType(P^.ItemType) = vDirectory then LocalList.Add(APath + String(P^.FName)) else AddEntry(APath + String(P^.FName), False, True); - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); - P := malloc(SizeOf(TVFSItem)); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSListNext(FGlobs, PChar(GetPath), P); until (Res <> cVFS_OK); - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); FSourcePlugin.FVFSListClose(FGlobs); if LocalList.Count > 0 then @@ -806,15 +806,15 @@ begin on E: Exception do DebugMsg(['*** TVFSEngine.FillDirFiles(APath=', APath, ', Level=', ALevel, ') -Exception: ', E.Message]); end; finally - P := malloc(SizeOf(TVFSItem)); + P := real_libc_malloc(SizeOf(TVFSItem)); memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); if Res <> cVFS_OK then DebugMsg(['*** FillDirFiles - VFSFileInfo(', APath, ') failed. Code = ', Res]); AddEntry(APath, True, False); - if P^.FName <> nil then libc_free(P^.FName); - if P^.FDisplayName <> nil then libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then libc_free(P^.sLinkTo); - libc_free(P); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); LocalList.Free; FilesList.Free; -- cgit v1.2.3