ISLzmaDec.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. ISLzmaDec.c, by Jordan Russell for Inno Setup
  3. This file is public domain (like the LZMA SDK)
  4. LzmaDec.c + Lzma2Dec.c + additional helper functions used by Compression.LZMADecompressor.pas
  5. */
  6. #include "../../../../Components/Lzma2/LzmaDec.c"
  7. #include "../../../../Components/Lzma2/Lzma2Dec.c"
  8. SRes IS_LzmaDec_Init(CLzmaDec *state, size_t stateSize, const Byte *props,
  9. unsigned propsSize, ISzAlloc *alloc)
  10. {
  11. if (stateSize != sizeof(*state)) {
  12. return SZ_ERROR_PARAM;
  13. }
  14. // Not needed; just sets fields to 0, which will leak memory if Init was already called previously
  15. //LzmaDec_Construct(state);
  16. RINOK(LzmaDec_Allocate(state, props, propsSize, alloc));
  17. LzmaDec_Init(state);
  18. return SZ_OK;
  19. }
  20. size_t IS_LzmaDec_StateSize()
  21. {
  22. return sizeof(CLzmaDec);
  23. }
  24. SRes IS_Lzma2Dec_Init(CLzma2Dec *state, size_t stateSize, Byte prop,
  25. ISzAlloc *alloc)
  26. {
  27. if (stateSize != sizeof(*state)) {
  28. return SZ_ERROR_PARAM;
  29. }
  30. // Not needed; just sets fields to 0, which will leak memory if Init was already called previously
  31. //Lzma2Dec_Construct(state);
  32. RINOK(Lzma2Dec_Allocate(state, prop, alloc));
  33. Lzma2Dec_Init(state);
  34. return SZ_OK;
  35. }
  36. size_t IS_Lzma2Dec_StateSize()
  37. {
  38. return sizeof(CLzma2Dec);
  39. }
  40. void IS_Lzma2Dec_Free(CLzma2Dec *state, ISzAlloc *alloc)
  41. {
  42. // This exists because Lzma2Dec_Free is a macro
  43. Lzma2Dec_Free(state, alloc);
  44. }