531-debloat_lzma.patch 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. From 3fd297761ac246c54d7723c57fca95c112b99465 Mon Sep 17 00:00:00 2001
  2. From: Felix Fietkau <nbd@nbd.name>
  3. Date: Sat, 15 Jul 2017 21:15:44 +0200
  4. Subject: lzma: de-bloat the lzma library used by jffs2
  5. lede-commit: 3fd1dd08fbcbb78b34efefd32c3032e5c99108d6
  6. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  7. ---
  8. include/linux/lzma/LzFind.h | 17 ---
  9. include/linux/lzma/LzmaDec.h | 101 ---------------
  10. include/linux/lzma/LzmaEnc.h | 20 ---
  11. lib/lzma/LzFind.c | 287 ++++---------------------------------------
  12. lib/lzma/LzmaDec.c | 86 +------------
  13. lib/lzma/LzmaEnc.c | 172 ++------------------------
  14. 6 files changed, 42 insertions(+), 641 deletions(-)
  15. --- a/include/linux/lzma/LzFind.h
  16. +++ b/include/linux/lzma/LzFind.h
  17. @@ -55,11 +55,6 @@ typedef struct _CMatchFinder
  18. #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
  19. -int MatchFinder_NeedMove(CMatchFinder *p);
  20. -Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
  21. -void MatchFinder_MoveBlock(CMatchFinder *p);
  22. -void MatchFinder_ReadIfRequired(CMatchFinder *p);
  23. -
  24. void MatchFinder_Construct(CMatchFinder *p);
  25. /* Conditions:
  26. @@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,
  27. UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
  28. ISzAlloc *alloc);
  29. void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
  30. -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
  31. -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
  32. -
  33. -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
  34. - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
  35. - UInt32 *distances, UInt32 maxLen);
  36. /*
  37. Conditions:
  38. @@ -102,12 +91,6 @@ typedef struct _IMatchFinder
  39. void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
  40. -void MatchFinder_Init(CMatchFinder *p);
  41. -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
  42. -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
  43. -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
  44. -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
  45. -
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. --- a/include/linux/lzma/LzmaDec.h
  50. +++ b/include/linux/lzma/LzmaDec.h
  51. @@ -31,14 +31,6 @@ typedef struct _CLzmaProps
  52. UInt32 dicSize;
  53. } CLzmaProps;
  54. -/* LzmaProps_Decode - decodes properties
  55. -Returns:
  56. - SZ_OK
  57. - SZ_ERROR_UNSUPPORTED - Unsupported properties
  58. -*/
  59. -
  60. -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
  61. -
  62. /* ---------- LZMA Decoder state ---------- */
  63. @@ -70,8 +62,6 @@ typedef struct
  64. #define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
  65. -void LzmaDec_Init(CLzmaDec *p);
  66. -
  67. /* There are two types of LZMA streams:
  68. 0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
  69. 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
  70. @@ -108,97 +98,6 @@ typedef enum
  71. /* ELzmaStatus is used only as output value for function call */
  72. -
  73. -/* ---------- Interfaces ---------- */
  74. -
  75. -/* There are 3 levels of interfaces:
  76. - 1) Dictionary Interface
  77. - 2) Buffer Interface
  78. - 3) One Call Interface
  79. - You can select any of these interfaces, but don't mix functions from different
  80. - groups for same object. */
  81. -
  82. -
  83. -/* There are two variants to allocate state for Dictionary Interface:
  84. - 1) LzmaDec_Allocate / LzmaDec_Free
  85. - 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
  86. - You can use variant 2, if you set dictionary buffer manually.
  87. - For Buffer Interface you must always use variant 1.
  88. -
  89. -LzmaDec_Allocate* can return:
  90. - SZ_OK
  91. - SZ_ERROR_MEM - Memory allocation error
  92. - SZ_ERROR_UNSUPPORTED - Unsupported properties
  93. -*/
  94. -
  95. -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
  96. -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
  97. -
  98. -SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
  99. -void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
  100. -
  101. -/* ---------- Dictionary Interface ---------- */
  102. -
  103. -/* You can use it, if you want to eliminate the overhead for data copying from
  104. - dictionary to some other external buffer.
  105. - You must work with CLzmaDec variables directly in this interface.
  106. -
  107. - STEPS:
  108. - LzmaDec_Constr()
  109. - LzmaDec_Allocate()
  110. - for (each new stream)
  111. - {
  112. - LzmaDec_Init()
  113. - while (it needs more decompression)
  114. - {
  115. - LzmaDec_DecodeToDic()
  116. - use data from CLzmaDec::dic and update CLzmaDec::dicPos
  117. - }
  118. - }
  119. - LzmaDec_Free()
  120. -*/
  121. -
  122. -/* LzmaDec_DecodeToDic
  123. -
  124. - The decoding to internal dictionary buffer (CLzmaDec::dic).
  125. - You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
  126. -
  127. -finishMode:
  128. - It has meaning only if the decoding reaches output limit (dicLimit).
  129. - LZMA_FINISH_ANY - Decode just dicLimit bytes.
  130. - LZMA_FINISH_END - Stream must be finished after dicLimit.
  131. -
  132. -Returns:
  133. - SZ_OK
  134. - status:
  135. - LZMA_STATUS_FINISHED_WITH_MARK
  136. - LZMA_STATUS_NOT_FINISHED
  137. - LZMA_STATUS_NEEDS_MORE_INPUT
  138. - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
  139. - SZ_ERROR_DATA - Data error
  140. -*/
  141. -
  142. -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
  143. - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
  144. -
  145. -
  146. -/* ---------- Buffer Interface ---------- */
  147. -
  148. -/* It's zlib-like interface.
  149. - See LzmaDec_DecodeToDic description for information about STEPS and return results,
  150. - but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
  151. - to work with CLzmaDec variables manually.
  152. -
  153. -finishMode:
  154. - It has meaning only if the decoding reaches output limit (*destLen).
  155. - LZMA_FINISH_ANY - Decode just destLen bytes.
  156. - LZMA_FINISH_END - Stream must be finished after (*destLen).
  157. -*/
  158. -
  159. -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
  160. - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
  161. -
  162. -
  163. /* ---------- One Call Interface ---------- */
  164. /* LzmaDecode
  165. --- a/include/linux/lzma/LzmaEnc.h
  166. +++ b/include/linux/lzma/LzmaEnc.h
  167. @@ -31,9 +31,6 @@ typedef struct _CLzmaEncProps
  168. } CLzmaEncProps;
  169. void LzmaEncProps_Init(CLzmaEncProps *p);
  170. -void LzmaEncProps_Normalize(CLzmaEncProps *p);
  171. -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
  172. -
  173. /* ---------- CLzmaEncHandle Interface ---------- */
  174. @@ -53,26 +50,9 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
  175. void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
  176. SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
  177. SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
  178. -SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
  179. - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
  180. SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  181. int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
  182. -/* ---------- One Call Interface ---------- */
  183. -
  184. -/* LzmaEncode
  185. -Return code:
  186. - SZ_OK - OK
  187. - SZ_ERROR_MEM - Memory allocation error
  188. - SZ_ERROR_PARAM - Incorrect paramater
  189. - SZ_ERROR_OUTPUT_EOF - output buffer overflow
  190. - SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
  191. -*/
  192. -
  193. -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  194. - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
  195. - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
  196. -
  197. #ifdef __cplusplus
  198. }
  199. #endif
  200. --- a/lib/lzma/LzFind.c
  201. +++ b/lib/lzma/LzFind.c
  202. @@ -14,9 +14,15 @@
  203. #define kStartMaxLen 3
  204. +#if 0
  205. +#define DIRECT_INPUT p->directInput
  206. +#else
  207. +#define DIRECT_INPUT 1
  208. +#endif
  209. +
  210. static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
  211. {
  212. - if (!p->directInput)
  213. + if (!DIRECT_INPUT)
  214. {
  215. alloc->Free(alloc, p->bufferBase);
  216. p->bufferBase = 0;
  217. @@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder
  218. static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
  219. {
  220. UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
  221. - if (p->directInput)
  222. + if (DIRECT_INPUT)
  223. {
  224. p->blockSize = blockSize;
  225. return 1;
  226. @@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinde
  227. return (p->bufferBase != 0);
  228. }
  229. -Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
  230. -Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
  231. +static Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
  232. +static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
  233. -UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
  234. +static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
  235. -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
  236. +static void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
  237. {
  238. p->posLimit -= subValue;
  239. p->pos -= subValue;
  240. @@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatch
  241. {
  242. if (p->streamEndWasReached || p->result != SZ_OK)
  243. return;
  244. - if (p->directInput)
  245. + if (DIRECT_INPUT)
  246. {
  247. UInt32 curSize = 0xFFFFFFFF - p->streamPos;
  248. if (curSize > p->directInputRem)
  249. @@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatch
  250. }
  251. }
  252. -void MatchFinder_MoveBlock(CMatchFinder *p)
  253. +static void MatchFinder_MoveBlock(CMatchFinder *p)
  254. {
  255. memmove(p->bufferBase,
  256. p->buffer - p->keepSizeBefore,
  257. @@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder
  258. p->buffer = p->bufferBase + p->keepSizeBefore;
  259. }
  260. -int MatchFinder_NeedMove(CMatchFinder *p)
  261. +static int MatchFinder_NeedMove(CMatchFinder *p)
  262. {
  263. - if (p->directInput)
  264. + if (DIRECT_INPUT)
  265. return 0;
  266. /* if (p->streamEndWasReached) return 0; */
  267. return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
  268. }
  269. -void MatchFinder_ReadIfRequired(CMatchFinder *p)
  270. -{
  271. - if (p->streamEndWasReached)
  272. - return;
  273. - if (p->keepSizeAfter >= p->streamPos - p->pos)
  274. - MatchFinder_ReadBlock(p);
  275. -}
  276. -
  277. static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
  278. {
  279. if (MatchFinder_NeedMove(p))
  280. @@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatch
  281. p->posLimit = p->pos + limit;
  282. }
  283. -void MatchFinder_Init(CMatchFinder *p)
  284. +static void MatchFinder_Init(CMatchFinder *p)
  285. {
  286. UInt32 i;
  287. for (i = 0; i < p->hashSizeSum; i++)
  288. @@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CM
  289. return (p->pos - p->historySize - 1) & kNormalizeMask;
  290. }
  291. -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
  292. +static void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
  293. {
  294. UInt32 i;
  295. for (i = 0; i < numItems; i++)
  296. @@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMat
  297. MatchFinder_SetLimits(p);
  298. }
  299. -static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
  300. - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
  301. - UInt32 *distances, UInt32 maxLen)
  302. -{
  303. - son[_cyclicBufferPos] = curMatch;
  304. - for (;;)
  305. - {
  306. - UInt32 delta = pos - curMatch;
  307. - if (cutValue-- == 0 || delta >= _cyclicBufferSize)
  308. - return distances;
  309. - {
  310. - const Byte *pb = cur - delta;
  311. - curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
  312. - if (pb[maxLen] == cur[maxLen] && *pb == *cur)
  313. - {
  314. - UInt32 len = 0;
  315. - while (++len != lenLimit)
  316. - if (pb[len] != cur[len])
  317. - break;
  318. - if (maxLen < len)
  319. - {
  320. - *distances++ = maxLen = len;
  321. - *distances++ = delta - 1;
  322. - if (len == lenLimit)
  323. - return distances;
  324. - }
  325. - }
  326. - }
  327. - }
  328. -}
  329. -
  330. -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
  331. +static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
  332. UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
  333. UInt32 *distances, UInt32 maxLen)
  334. {
  335. @@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLi
  336. p->buffer++; \
  337. if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
  338. -#define MOVE_POS_RET MOVE_POS return offset;
  339. -
  340. static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
  341. +#define MOVE_POS_RET MatchFinder_MovePos(p); return offset;
  342. +
  343. #define GET_MATCHES_HEADER2(minLen, ret_op) \
  344. UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
  345. lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
  346. @@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFi
  347. distances + offset, maxLen) - distances); MOVE_POS_RET;
  348. #define SKIP_FOOTER \
  349. - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
  350. -
  351. -static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  352. -{
  353. - UInt32 offset;
  354. - GET_MATCHES_HEADER(2)
  355. - HASH2_CALC;
  356. - curMatch = p->hash[hashValue];
  357. - p->hash[hashValue] = p->pos;
  358. - offset = 0;
  359. - GET_MATCHES_FOOTER(offset, 1)
  360. -}
  361. -
  362. -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  363. -{
  364. - UInt32 offset;
  365. - GET_MATCHES_HEADER(3)
  366. - HASH_ZIP_CALC;
  367. - curMatch = p->hash[hashValue];
  368. - p->hash[hashValue] = p->pos;
  369. - offset = 0;
  370. - GET_MATCHES_FOOTER(offset, 2)
  371. -}
  372. -
  373. -static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  374. -{
  375. - UInt32 hash2Value, delta2, maxLen, offset;
  376. - GET_MATCHES_HEADER(3)
  377. -
  378. - HASH3_CALC;
  379. -
  380. - delta2 = p->pos - p->hash[hash2Value];
  381. - curMatch = p->hash[kFix3HashSize + hashValue];
  382. -
  383. - p->hash[hash2Value] =
  384. - p->hash[kFix3HashSize + hashValue] = p->pos;
  385. -
  386. -
  387. - maxLen = 2;
  388. - offset = 0;
  389. - if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
  390. - {
  391. - for (; maxLen != lenLimit; maxLen++)
  392. - if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
  393. - break;
  394. - distances[0] = maxLen;
  395. - distances[1] = delta2 - 1;
  396. - offset = 2;
  397. - if (maxLen == lenLimit)
  398. - {
  399. - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
  400. - MOVE_POS_RET;
  401. - }
  402. - }
  403. - GET_MATCHES_FOOTER(offset, maxLen)
  404. -}
  405. + SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p);
  406. static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  407. {
  408. @@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches
  409. GET_MATCHES_FOOTER(offset, maxLen)
  410. }
  411. -static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  412. -{
  413. - UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
  414. - GET_MATCHES_HEADER(4)
  415. -
  416. - HASH4_CALC;
  417. -
  418. - delta2 = p->pos - p->hash[ hash2Value];
  419. - delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
  420. - curMatch = p->hash[kFix4HashSize + hashValue];
  421. -
  422. - p->hash[ hash2Value] =
  423. - p->hash[kFix3HashSize + hash3Value] =
  424. - p->hash[kFix4HashSize + hashValue] = p->pos;
  425. -
  426. - maxLen = 1;
  427. - offset = 0;
  428. - if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
  429. - {
  430. - distances[0] = maxLen = 2;
  431. - distances[1] = delta2 - 1;
  432. - offset = 2;
  433. - }
  434. - if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
  435. - {
  436. - maxLen = 3;
  437. - distances[offset + 1] = delta3 - 1;
  438. - offset += 2;
  439. - delta2 = delta3;
  440. - }
  441. - if (offset != 0)
  442. - {
  443. - for (; maxLen != lenLimit; maxLen++)
  444. - if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
  445. - break;
  446. - distances[offset - 2] = maxLen;
  447. - if (maxLen == lenLimit)
  448. - {
  449. - p->son[p->cyclicBufferPos] = curMatch;
  450. - MOVE_POS_RET;
  451. - }
  452. - }
  453. - if (maxLen < 3)
  454. - maxLen = 3;
  455. - offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
  456. - distances + offset, maxLen) - (distances));
  457. - MOVE_POS_RET
  458. -}
  459. -
  460. -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  461. -{
  462. - UInt32 offset;
  463. - GET_MATCHES_HEADER(3)
  464. - HASH_ZIP_CALC;
  465. - curMatch = p->hash[hashValue];
  466. - p->hash[hashValue] = p->pos;
  467. - offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
  468. - distances, 2) - (distances));
  469. - MOVE_POS_RET
  470. -}
  471. -
  472. -static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
  473. -{
  474. - do
  475. - {
  476. - SKIP_HEADER(2)
  477. - HASH2_CALC;
  478. - curMatch = p->hash[hashValue];
  479. - p->hash[hashValue] = p->pos;
  480. - SKIP_FOOTER
  481. - }
  482. - while (--num != 0);
  483. -}
  484. -
  485. -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
  486. -{
  487. - do
  488. - {
  489. - SKIP_HEADER(3)
  490. - HASH_ZIP_CALC;
  491. - curMatch = p->hash[hashValue];
  492. - p->hash[hashValue] = p->pos;
  493. - SKIP_FOOTER
  494. - }
  495. - while (--num != 0);
  496. -}
  497. -
  498. -static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
  499. -{
  500. - do
  501. - {
  502. - UInt32 hash2Value;
  503. - SKIP_HEADER(3)
  504. - HASH3_CALC;
  505. - curMatch = p->hash[kFix3HashSize + hashValue];
  506. - p->hash[hash2Value] =
  507. - p->hash[kFix3HashSize + hashValue] = p->pos;
  508. - SKIP_FOOTER
  509. - }
  510. - while (--num != 0);
  511. -}
  512. -
  513. static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
  514. {
  515. do
  516. @@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchF
  517. while (--num != 0);
  518. }
  519. -static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
  520. -{
  521. - do
  522. - {
  523. - UInt32 hash2Value, hash3Value;
  524. - SKIP_HEADER(4)
  525. - HASH4_CALC;
  526. - curMatch = p->hash[kFix4HashSize + hashValue];
  527. - p->hash[ hash2Value] =
  528. - p->hash[kFix3HashSize + hash3Value] =
  529. - p->hash[kFix4HashSize + hashValue] = p->pos;
  530. - p->son[p->cyclicBufferPos] = curMatch;
  531. - MOVE_POS
  532. - }
  533. - while (--num != 0);
  534. -}
  535. -
  536. -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
  537. -{
  538. - do
  539. - {
  540. - SKIP_HEADER(3)
  541. - HASH_ZIP_CALC;
  542. - curMatch = p->hash[hashValue];
  543. - p->hash[hashValue] = p->pos;
  544. - p->son[p->cyclicBufferPos] = curMatch;
  545. - MOVE_POS
  546. - }
  547. - while (--num != 0);
  548. -}
  549. -
  550. void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
  551. {
  552. vTable->Init = (Mf_Init_Func)MatchFinder_Init;
  553. vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
  554. vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
  555. vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
  556. - if (!p->btMode)
  557. - {
  558. - vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
  559. - vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
  560. - }
  561. - else if (p->numHashBytes == 2)
  562. - {
  563. - vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
  564. - vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
  565. - }
  566. - else if (p->numHashBytes == 3)
  567. - {
  568. - vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
  569. - vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
  570. - }
  571. - else
  572. - {
  573. - vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
  574. - vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
  575. - }
  576. + vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
  577. + vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
  578. }
  579. --- a/lib/lzma/LzmaDec.c
  580. +++ b/lib/lzma/LzmaDec.c
  581. @@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,
  582. p->needFlush = 0;
  583. }
  584. -void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
  585. +static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
  586. {
  587. p->needFlush = 1;
  588. p->remainLen = 0;
  589. @@ -698,7 +698,7 @@ void LzmaDec_InitDicAndState(CLzmaDec *p
  590. p->needInitState = 1;
  591. }
  592. -void LzmaDec_Init(CLzmaDec *p)
  593. +static void LzmaDec_Init(CLzmaDec *p)
  594. {
  595. p->dicPos = 0;
  596. LzmaDec_InitDicAndState(p, True, True);
  597. @@ -716,7 +716,7 @@ static void LzmaDec_InitStateReal(CLzmaD
  598. p->needInitState = 0;
  599. }
  600. -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
  601. +static SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
  602. ELzmaFinishMode finishMode, ELzmaStatus *status)
  603. {
  604. SizeT inSize = *srcLen;
  605. @@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si
  606. return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
  607. }
  608. -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
  609. -{
  610. - SizeT outSize = *destLen;
  611. - SizeT inSize = *srcLen;
  612. - *srcLen = *destLen = 0;
  613. - for (;;)
  614. - {
  615. - SizeT inSizeCur = inSize, outSizeCur, dicPos;
  616. - ELzmaFinishMode curFinishMode;
  617. - SRes res;
  618. - if (p->dicPos == p->dicBufSize)
  619. - p->dicPos = 0;
  620. - dicPos = p->dicPos;
  621. - if (outSize > p->dicBufSize - dicPos)
  622. - {
  623. - outSizeCur = p->dicBufSize;
  624. - curFinishMode = LZMA_FINISH_ANY;
  625. - }
  626. - else
  627. - {
  628. - outSizeCur = dicPos + outSize;
  629. - curFinishMode = finishMode;
  630. - }
  631. -
  632. - res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
  633. - src += inSizeCur;
  634. - inSize -= inSizeCur;
  635. - *srcLen += inSizeCur;
  636. - outSizeCur = p->dicPos - dicPos;
  637. - memcpy(dest, p->dic + dicPos, outSizeCur);
  638. - dest += outSizeCur;
  639. - outSize -= outSizeCur;
  640. - *destLen += outSizeCur;
  641. - if (res != 0)
  642. - return res;
  643. - if (outSizeCur == 0 || outSize == 0)
  644. - return SZ_OK;
  645. - }
  646. -}
  647. -
  648. -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
  649. +static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
  650. {
  651. alloc->Free(alloc, p->probs);
  652. p->probs = 0;
  653. }
  654. -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
  655. -{
  656. - alloc->Free(alloc, p->dic);
  657. - p->dic = 0;
  658. -}
  659. -
  660. -void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
  661. -{
  662. - LzmaDec_FreeProbs(p, alloc);
  663. - LzmaDec_FreeDict(p, alloc);
  664. -}
  665. -
  666. -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
  667. +static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
  668. {
  669. UInt32 dicSize;
  670. Byte d;
  671. @@ -935,7 +883,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma
  672. return SZ_OK;
  673. }
  674. -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
  675. +static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
  676. {
  677. CLzmaProps propNew;
  678. RINOK(LzmaProps_Decode(&propNew, props, propsSize));
  679. @@ -943,28 +891,6 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p,
  680. p->prop = propNew;
  681. return SZ_OK;
  682. }
  683. -
  684. -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
  685. -{
  686. - CLzmaProps propNew;
  687. - SizeT dicBufSize;
  688. - RINOK(LzmaProps_Decode(&propNew, props, propsSize));
  689. - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
  690. - dicBufSize = propNew.dicSize;
  691. - if (p->dic == 0 || dicBufSize != p->dicBufSize)
  692. - {
  693. - LzmaDec_FreeDict(p, alloc);
  694. - p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
  695. - if (p->dic == 0)
  696. - {
  697. - LzmaDec_FreeProbs(p, alloc);
  698. - return SZ_ERROR_MEM;
  699. - }
  700. - }
  701. - p->dicBufSize = dicBufSize;
  702. - p->prop = propNew;
  703. - return SZ_OK;
  704. -}
  705. SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
  706. const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
  707. --- a/lib/lzma/LzmaEnc.c
  708. +++ b/lib/lzma/LzmaEnc.c
  709. @@ -53,7 +53,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
  710. p->writeEndMark = 0;
  711. }
  712. -void LzmaEncProps_Normalize(CLzmaEncProps *p)
  713. +static void LzmaEncProps_Normalize(CLzmaEncProps *p)
  714. {
  715. int level = p->level;
  716. if (level < 0) level = 5;
  717. @@ -76,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProp
  718. #endif
  719. }
  720. -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
  721. +static UInt32 __maybe_unused LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
  722. {
  723. CLzmaEncProps props = *props2;
  724. LzmaEncProps_Normalize(&props);
  725. @@ -93,7 +93,7 @@ UInt32 LzmaEncProps_GetDictSize(const CL
  726. #define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
  727. -UInt32 GetPosSlot1(UInt32 pos)
  728. +static UInt32 GetPosSlot1(UInt32 pos)
  729. {
  730. UInt32 res;
  731. BSR2_RET(pos, res);
  732. @@ -107,7 +107,7 @@ UInt32 GetPosSlot1(UInt32 pos)
  733. #define kNumLogBits (9 + (int)sizeof(size_t) / 2)
  734. #define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
  735. -void LzmaEnc_FastPosInit(Byte *g_FastPos)
  736. +static void LzmaEnc_FastPosInit(Byte *g_FastPos)
  737. {
  738. int c = 2, slotFast;
  739. g_FastPos[0] = 0;
  740. @@ -339,58 +339,6 @@ typedef struct
  741. CSaveState saveState;
  742. } CLzmaEnc;
  743. -void LzmaEnc_SaveState(CLzmaEncHandle pp)
  744. -{
  745. - CLzmaEnc *p = (CLzmaEnc *)pp;
  746. - CSaveState *dest = &p->saveState;
  747. - int i;
  748. - dest->lenEnc = p->lenEnc;
  749. - dest->repLenEnc = p->repLenEnc;
  750. - dest->state = p->state;
  751. -
  752. - for (i = 0; i < kNumStates; i++)
  753. - {
  754. - memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
  755. - memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
  756. - }
  757. - for (i = 0; i < kNumLenToPosStates; i++)
  758. - memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
  759. - memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
  760. - memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
  761. - memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
  762. - memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
  763. - memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
  764. - memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
  765. - memcpy(dest->reps, p->reps, sizeof(p->reps));
  766. - memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
  767. -}
  768. -
  769. -void LzmaEnc_RestoreState(CLzmaEncHandle pp)
  770. -{
  771. - CLzmaEnc *dest = (CLzmaEnc *)pp;
  772. - const CSaveState *p = &dest->saveState;
  773. - int i;
  774. - dest->lenEnc = p->lenEnc;
  775. - dest->repLenEnc = p->repLenEnc;
  776. - dest->state = p->state;
  777. -
  778. - for (i = 0; i < kNumStates; i++)
  779. - {
  780. - memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
  781. - memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
  782. - }
  783. - for (i = 0; i < kNumLenToPosStates; i++)
  784. - memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
  785. - memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
  786. - memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
  787. - memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
  788. - memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
  789. - memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
  790. - memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
  791. - memcpy(dest->reps, p->reps, sizeof(p->reps));
  792. - memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
  793. -}
  794. -
  795. SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
  796. {
  797. CLzmaEnc *p = (CLzmaEnc *)pp;
  798. @@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeE
  799. while (symbol < 0x10000);
  800. }
  801. -void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
  802. +static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
  803. {
  804. UInt32 i;
  805. for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
  806. @@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc
  807. p->matchPriceCount = 0;
  808. }
  809. -void LzmaEnc_Construct(CLzmaEnc *p)
  810. +static void LzmaEnc_Construct(CLzmaEnc *p)
  811. {
  812. RangeEnc_Construct(&p->rc);
  813. MatchFinder_Construct(&p->matchFinderBase);
  814. @@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
  815. return p;
  816. }
  817. -void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
  818. +static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
  819. {
  820. alloc->Free(alloc, p->litProbs);
  821. alloc->Free(alloc, p->saveState.litProbs);
  822. @@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAl
  823. p->saveState.litProbs = 0;
  824. }
  825. -void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
  826. +static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
  827. {
  828. #ifndef _7ZIP_ST
  829. MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
  830. @@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, U
  831. return SZ_OK;
  832. }
  833. -void LzmaEnc_Init(CLzmaEnc *p)
  834. +static void LzmaEnc_Init(CLzmaEnc *p)
  835. {
  836. UInt32 i;
  837. p->state = 0;
  838. @@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p)
  839. p->lpMask = (1 << p->lp) - 1;
  840. }
  841. -void LzmaEnc_InitPrices(CLzmaEnc *p)
  842. +static void LzmaEnc_InitPrices(CLzmaEnc *p)
  843. {
  844. if (!p->fastMode)
  845. {
  846. @@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEn
  847. return SZ_OK;
  848. }
  849. -static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
  850. - ISzAlloc *alloc, ISzAlloc *allocBig)
  851. -{
  852. - CLzmaEnc *p = (CLzmaEnc *)pp;
  853. - p->matchFinderBase.stream = inStream;
  854. - p->needInit = 1;
  855. - p->rc.outStream = outStream;
  856. - return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
  857. -}
  858. -
  859. -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
  860. - ISeqInStream *inStream, UInt32 keepWindowSize,
  861. - ISzAlloc *alloc, ISzAlloc *allocBig)
  862. -{
  863. - CLzmaEnc *p = (CLzmaEnc *)pp;
  864. - p->matchFinderBase.stream = inStream;
  865. - p->needInit = 1;
  866. - return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
  867. -}
  868. -
  869. static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
  870. {
  871. p->matchFinderBase.directInput = 1;
  872. @@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc
  873. p->matchFinderBase.directInputRem = srcLen;
  874. }
  875. -SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
  876. +static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
  877. UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
  878. {
  879. CLzmaEnc *p = (CLzmaEnc *)pp;
  880. @@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p
  881. return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
  882. }
  883. -void LzmaEnc_Finish(CLzmaEncHandle pp)
  884. +static void LzmaEnc_Finish(CLzmaEncHandle pp)
  885. {
  886. #ifndef _7ZIP_ST
  887. CLzmaEnc *p = (CLzmaEnc *)pp;
  888. @@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const vo
  889. return size;
  890. }
  891. -
  892. -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
  893. -{
  894. - const CLzmaEnc *p = (CLzmaEnc *)pp;
  895. - return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
  896. -}
  897. -
  898. -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
  899. -{
  900. - const CLzmaEnc *p = (CLzmaEnc *)pp;
  901. - return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
  902. -}
  903. -
  904. -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
  905. - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
  906. -{
  907. - CLzmaEnc *p = (CLzmaEnc *)pp;
  908. - UInt64 nowPos64;
  909. - SRes res;
  910. - CSeqOutStreamBuf outStream;
  911. -
  912. - outStream.funcTable.Write = MyWrite;
  913. - outStream.data = dest;
  914. - outStream.rem = *destLen;
  915. - outStream.overflow = False;
  916. -
  917. - p->writeEndMark = False;
  918. - p->finished = False;
  919. - p->result = SZ_OK;
  920. -
  921. - if (reInit)
  922. - LzmaEnc_Init(p);
  923. - LzmaEnc_InitPrices(p);
  924. - nowPos64 = p->nowPos64;
  925. - RangeEnc_Init(&p->rc);
  926. - p->rc.outStream = &outStream.funcTable;
  927. -
  928. - res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
  929. -
  930. - *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
  931. - *destLen -= outStream.rem;
  932. - if (outStream.overflow)
  933. - return SZ_ERROR_OUTPUT_EOF;
  934. -
  935. - return res;
  936. -}
  937. -
  938. static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
  939. {
  940. SRes res = SZ_OK;
  941. @@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p,
  942. return res;
  943. }
  944. -SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
  945. - ISzAlloc *alloc, ISzAlloc *allocBig)
  946. -{
  947. - RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
  948. - return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
  949. -}
  950. -
  951. SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
  952. {
  953. CLzmaEnc *p = (CLzmaEnc *)pp;
  954. @@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp
  955. return SZ_ERROR_OUTPUT_EOF;
  956. return res;
  957. }
  958. -
  959. -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  960. - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
  961. - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
  962. -{
  963. - CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
  964. - SRes res;
  965. - if (p == 0)
  966. - return SZ_ERROR_MEM;
  967. -
  968. - res = LzmaEnc_SetProps(p, props);
  969. - if (res == SZ_OK)
  970. - {
  971. - res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
  972. - if (res == SZ_OK)
  973. - res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
  974. - writeEndMark, progress, alloc, allocBig);
  975. - }
  976. -
  977. - LzmaEnc_Destroy(p, alloc, allocBig);
  978. - return res;
  979. -}