… | |
… | |
112 | const u8 *in_end = ip + in_len; |
112 | const u8 *in_end = ip + in_len; |
113 | u8 *out_end = op + out_len; |
113 | u8 *out_end = op + out_len; |
114 | const u8 *ref; |
114 | const u8 *ref; |
115 | |
115 | |
116 | unsigned int hval; |
116 | unsigned int hval; |
|
|
117 | #if WIN32 |
|
|
118 | unsigned _int64 off; /* workaround for microsoft bug (they claim to support POSIX) */ |
|
|
119 | #else |
117 | unsigned long off; |
120 | unsigned long off; |
|
|
121 | #endif |
118 | int lit; |
122 | int lit; |
119 | |
123 | |
120 | if (!in_len || !out_len) |
124 | if (!in_len || !out_len) |
121 | return 0; |
125 | return 0; |
122 | |
126 | |
… | |
… | |
254 | lit = 0; op++; /* start run */ |
258 | lit = 0; op++; /* start run */ |
255 | } |
259 | } |
256 | } |
260 | } |
257 | } |
261 | } |
258 | |
262 | |
259 | if (op + 2 > out_end) /* at most 2 bytes can be missing here */ |
263 | if (op + 3 > out_end) /* at most 3 bytes can be missing here */ |
260 | return 0; |
264 | return 0; |
261 | |
265 | |
262 | while (ip < in_end) |
266 | while (ip < in_end) |
263 | { |
267 | { |
264 | lit++; *op++ = *ip++; |
268 | lit++; *op++ = *ip++; |
|
|
269 | |
|
|
270 | if (expect_false (lit == MAX_LIT)) |
|
|
271 | { |
|
|
272 | op [- lit - 1] = lit - 1; /* stop run */ |
|
|
273 | lit = 0; op++; /* start run */ |
|
|
274 | } |
265 | } |
275 | } |
266 | |
276 | |
267 | op [- lit - 1] = lit - 1; /* end run */ |
277 | op [- lit - 1] = lit - 1; /* end run */ |
268 | op -= !lit; /* undo run if length is zero */ |
278 | op -= !lit; /* undo run if length is zero */ |
269 | |
279 | |