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.26 by root, Tue Nov 13 11:30:37 2007 UTC vs.
Revision 1.31 by root, Tue May 6 22:49:18 2008 UTC

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
136 hval = NEXT (hval, ip); 140 hval = NEXT (hval, ip);
137 hslot = htab + IDX (hval); 141 hslot = htab + IDX (hval);
138 ref = *hslot; *hslot = ip; 142 ref = *hslot; *hslot = ip;
139 143
140 if (1 144 if (1
141#if INIT_HTAB && !USE_MEMCPY 145#if INIT_HTAB
142 && ref < ip /* the next test will actually take care of this, but this is faster */ 146 && ref < ip /* the next test will actually take care of this, but this is faster */
143#endif 147#endif
144 && (off = ip - ref - 1) < MAX_OFF 148 && (off = ip - ref - 1) < MAX_OFF
145 && ip + 4 < in_end 149 && ip + 4 < in_end
146 && ref > (u8 *)in_data 150 && ref > (u8 *)in_data
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines