2
0
Эх сурвалжийг харах

Simplify things by merging ISLzmaDec and ISLzmaDec2 into one file.

Martijn Laan 11 сар өмнө
parent
commit
42b08c596a

+ 0 - 9
Projects/Src/Compression.LZMADecompressor.pas

@@ -96,7 +96,6 @@ const
 { Compiled by Visual Studio 2022 using compile.bat
   To enable source debugging recompile using compile-bcc32c.bat }
 {$L Src\Compression.LZMADecompressor\Lzma2Decode\ISLzmaDec.obj}
-{$L Src\Compression.LZMADecompressor\Lzma2Decode\ISLzma2Dec.obj}
 
 function IS_LzmaDec_Init(var state: TLZMA1InternalDecoderState;
   stateSize: Cardinal; const props; propsSize: Cardinal;
@@ -118,14 +117,6 @@ function Lzma2Dec_DecodeToBuf(var state: TLZMA2InternalDecoderState; var dest;
 procedure IS_Lzma2Dec_Free(var state: TLZMA2InternalDecoderState;
   const alloc: TLZMAISzAlloc); cdecl; external name '_IS_Lzma2Dec_Free';
 
-procedure LzmaDec_Allocate; cdecl; external name '_LzmaDec_Allocate';
-procedure LzmaDec_AllocateProbs; cdecl; external name '_LzmaDec_AllocateProbs';
-procedure LzmaDec_DecodeToDic; cdecl; external name'_LzmaDec_DecodeToDic';
-procedure LzmaDec_FreeProbs; cdecl; external name '_LzmaDec_FreeProbs';
-procedure LzmaDec_Init; cdecl; external name '_LzmaDec_Init';
-procedure LzmaDec_InitDicAndState; cdecl; external name '_LzmaDec_InitDicAndState';
-procedure LzmaProps_Decode; cdecl; external name '_LzmaProps_Decode';
-
 function _memcpy(dest, src: Pointer; n: Cardinal): Pointer; cdecl;
 begin
   Move(src^, dest^, n);

+ 0 - 36
Projects/Src/Compression.LZMADecompressor/Lzma2Decode/ISLzma2Dec.c

@@ -1,36 +0,0 @@
-/*
-  ISLzma2Dec.c, by Jordan Russell for Inno Setup
-  This file is public domain (like the LZMA SDK)
-
-  Lzma2Dec.c + additional helper functions used by Compression.LZMADecompressor.pas
-*/
-
-#include "../../../../Components/Lzma2/Lzma2Dec.c"
-
-SRes IS_Lzma2Dec_Init(CLzma2Dec *state, size_t stateSize, Byte prop,
-	ISzAlloc *alloc)
-{
-	if (stateSize != sizeof(*state)) {
-		return SZ_ERROR_PARAM;
-	}
-
-	// Not needed; just sets fields to 0, which will leak memory if Init was already called previously
-	//Lzma2Dec_Construct(state);
-
-	RINOK(Lzma2Dec_Allocate(state, prop, alloc));
-	Lzma2Dec_Init(state);
-
-	return SZ_OK;
-}
-
-size_t IS_Lzma2Dec_StateSize()
-{
-  return sizeof(CLzma2Dec);
-}
-
-void IS_Lzma2Dec_Free(CLzma2Dec *state, ISzAlloc *alloc)
-{
-	// This exists because Lzma2Dec_Free is a macro
-
-	Lzma2Dec_Free(state, alloc);
-}

BIN
Projects/Src/Compression.LZMADecompressor/Lzma2Decode/ISLzma2Dec.obj


+ 31 - 2
Projects/Src/Compression.LZMADecompressor/Lzma2Decode/ISLzmaDec.c

@@ -2,10 +2,11 @@
   ISLzmaDec.c, by Jordan Russell for Inno Setup
   This file is public domain (like the LZMA SDK)
 
-  LzmaDec.c + additional helper functions used by Compression.LZMADecompressor.pas
+  LzmaDec.c + Lzma2Dec.c + additional helper functions used by Compression.LZMADecompressor.pas
 */
 
 #include "../../../../Components/Lzma2/LzmaDec.c"
+#include "../../../../Components/Lzma2/Lzma2Dec.c"
 
 SRes IS_LzmaDec_Init(CLzmaDec *state, size_t stateSize, const Byte *props,
 	unsigned propsSize, ISzAlloc *alloc)
@@ -26,4 +27,32 @@ SRes IS_LzmaDec_Init(CLzmaDec *state, size_t stateSize, const Byte *props,
 size_t IS_LzmaDec_StateSize()
 {
   return sizeof(CLzmaDec);
-}
+}
+
+SRes IS_Lzma2Dec_Init(CLzma2Dec *state, size_t stateSize, Byte prop,
+	ISzAlloc *alloc)
+{
+	if (stateSize != sizeof(*state)) {
+		return SZ_ERROR_PARAM;
+	}
+
+	// Not needed; just sets fields to 0, which will leak memory if Init was already called previously
+	//Lzma2Dec_Construct(state);
+
+	RINOK(Lzma2Dec_Allocate(state, prop, alloc));
+	Lzma2Dec_Init(state);
+
+	return SZ_OK;
+}
+
+size_t IS_Lzma2Dec_StateSize()
+{
+  return sizeof(CLzma2Dec);
+}
+
+void IS_Lzma2Dec_Free(CLzma2Dec *state, ISzAlloc *alloc)
+{
+	// This exists because Lzma2Dec_Free is a macro
+
+	Lzma2Dec_Free(state, alloc);
+}

BIN
Projects/Src/Compression.LZMADecompressor/Lzma2Decode/ISLzmaDec.obj


+ 3 - 3
Projects/Src/Compression.LZMADecompressor/Lzma2Decode/compile-bcc32c.bat

@@ -5,7 +5,7 @@ rem  Copyright (C) 1997-2024 Jordan Russell
 rem  Portions by Martijn Laan
 rem  For conditions of distribution and use, see LICENSE.TXT.
 rem
-rem  Batch file to compile  ISLzmaDec.c and ISLzma2Dec.c using Embarcadero's free
+rem  Batch file to compile ISLzmaDec.c using Embarcadero's free
 rem  C++ compiler from https://www.embarcadero.com/free-tools/ccompiler
 rem  with source debugging turned on
 
@@ -28,8 +28,8 @@ if "%BCCROOT%"=="" goto compilesettingserror
 
 rem -------------------------------------------------------------------------
 
-echo - Compiling ISLzmaDec.c and ISLzma2Dec.c
-"%BCCROOT%\bin\bcc32c.exe" -c -O2 -v ISLzmaDec.c ISLzma2Dec.c
+echo - Compiling ISLzmaDec.c
+"%BCCROOT%\bin\bcc32c.exe" -c -O2 -v ISLzmaDec.c
 if errorlevel 1 goto failed
 
 echo Success!

+ 3 - 3
Projects/Src/Compression.LZMADecompressor/Lzma2Decode/compile.bat

@@ -5,7 +5,7 @@ rem  Copyright (C) 1997-2024 Jordan Russell
 rem  Portions by Martijn Laan
 rem  For conditions of distribution and use, see LICENSE.TXT.
 rem
-rem  Batch file to compile ISLzmaDec.c and ISLzma2Dec.c
+rem  Batch file to compile ISLzmaDec.c
 
 setlocal
 
@@ -34,8 +34,8 @@ call "%VSTOOLSROOT%\VsDevCmd.bat"
 if errorlevel 1 goto exit
 echo.
 
-echo - Compiling ISLzmaDec.c and ISLzma2Dec.c
-cl.exe /c /O2 /GS- ISLzmaDec.c ISLzma2Dec.c
+echo - Compiling ISLzmaDec.c
+cl.exe /c /O2 /GS- ISLzmaDec.c
 if errorlevel 1 goto failed
 
 echo Success!

+ 1 - 1
README.md

@@ -207,7 +207,7 @@ code in the isscint repository.
 Compiled by Visual Studio 2005 from the [Projects\Src\Setup.HelperEXEs\Helper] directory and then
 stored in a compiled resource file.
 
-**Projects\Src\Compression.LZMADecompressor\Lzma2Decode\ISLzmaDec.obj**, **Projects\Src\Compression.LZMADecompressor\Lzma2Decode\ISLzma2Dec.obj** -
+**Projects\Src\Compression.LZMADecompressor\Lzma2Decode\ISLzmaDec.obj** -
 Compiled by Visual Studio 2022 from the [Projects\Src\Compression.LZMADecompressor\Lzma2Decode] directory.
 
 **Projects\Src\Compression.LZMA1SmallDecompressor\LzmaDecode\LzmaDecodeInno.obj** -