ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/liblzf/lzf_c.c
(Generate patch)

Comparing liblzf/lzf_c.c (file contents):
Revision 1.25 by root, Tue Nov 13 11:02:28 2007 UTC vs.
Revision 1.29 by root, Fri Nov 30 10:35:02 2007 UTC

136 hval = NEXT (hval, ip); 136 hval = NEXT (hval, ip);
137 hslot = htab + IDX (hval); 137 hslot = htab + IDX (hval);
138 ref = *hslot; *hslot = ip; 138 ref = *hslot; *hslot = ip;
139 139
140 if (1 140 if (1
141#if INIT_HTAB && !USE_MEMCPY 141#if INIT_HTAB
142 && ref < ip /* the next test will actually take care of this, but this is faster */ 142 && ref < ip /* the next test will actually take care of this, but this is faster */
143#endif 143#endif
144 && (off = ip - ref - 1) < MAX_OFF 144 && (off = ip - ref - 1) < MAX_OFF
145 && ip + 4 < in_end 145 && ip + 4 < in_end
146 && ref > (u8 *)in_data 146 && ref > (u8 *)in_data
157 /* match found at *ref++ */ 157 /* match found at *ref++ */
158 unsigned int len = 2; 158 unsigned int len = 2;
159 unsigned int maxlen = in_end - ip - len; 159 unsigned int maxlen = in_end - ip - len;
160 maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; 160 maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
161 161
162 if (maxlen > 8) maxlen = 8;//D
163
162 op [- lit - 1] = lit - 1; /* stop run */ 164 op [- lit - 1] = lit - 1; /* stop run */
163 op -= !lit; /* undo run if length is zero */ 165 op -= !lit; /* undo run if length is zero */
164 166
165 if (expect_false (op + 3 + 1 >= out_end)) 167 if (expect_false (op + 3 + 1 >= out_end))
166 return 0; 168 return 0;
235 htab[IDX (hval)] = ip; 237 htab[IDX (hval)] = ip;
236 ip++; 238 ip++;
237 } 239 }
238 while (len--); 240 while (len--);
239#endif 241#endif
242
240 lit = 0; op++; /* start run */ 243 lit = 0; op++; /* start run */
241 continue;
242 } 244 }
243 245 else
246 {
244 /* one more literal byte we must copy */ 247 /* one more literal byte we must copy */
245
246 if (expect_false (op >= out_end)) 248 if (expect_false (op >= out_end))
247 return 0; 249 return 0;
248 250
249 lit++; 251 lit++; *op++ = *ip++;
252
253 if (expect_false (lit == MAX_LIT))
254 {
255 op [- lit - 1] = lit - 1; /* stop run */
256 lit = 0; op++; /* start run */
257 }
258 }
259 }
260
261 if (op + 3 > out_end) /* at most 3 bytes can be missing here */
262 return 0;
263
264 while (ip < in_end)
265 {
250 *op++ = *ip++; 266 lit++; *op++ = *ip++;
251 267
252 if (expect_false (lit == MAX_LIT)) 268 if (expect_false (lit == MAX_LIT))
253 { 269 {
254 op [- lit - 1] = lit - 1; /* stop run */ 270 op [- lit - 1] = lit - 1; /* stop run */
255 lit = 0; op++; /* start run */ 271 lit = 0; op++; /* start run */
256 } 272 }
257 } 273 }
258 274
259 if (op + 2 >= out_end)
260 return 0;
261
262 while (ip < in_end)
263 {
264 lit++;
265 *op++ = *ip++;
266 }
267
268 op [- lit - 1] = lit - 1; /* end run */ 275 op [- lit - 1] = lit - 1; /* end run */
269 op -= !lit; /* undo run if length is zero */ 276 op -= !lit; /* undo run if length is zero */
270 277
271 return op - (u8 *)out_data; 278 return op - (u8 *)out_data;
272} 279}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines