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

Comparing liblzf/lzf_c_best.c (file contents):
Revision 1.1 by root, Thu Feb 16 05:43:19 2012 UTC vs.
Revision 1.3 by root, Sun Jan 11 01:32:04 2015 UTC

1/* 1/*
2 * Copyright (c) 2000-2012 Marc Alexander Lehmann <schmorp@schmorp.de> 2 * Copyright (c) 2000-2012 Marc Alexander Lehmann <schmorp@schmorp.de>
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without modifica- 4 * Redistribution and use in source and binary forms, with or without modifica-
5 * tion, are permitted provided that the following conditions are met: 5 * tion, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 * 9 *
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
16 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 17 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
18 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
70 u8 *op = (u8 *)out_data; 70 u8 *op = (u8 *)out_data;
71 const u8 *in_end = ip + in_len; 71 const u8 *in_end = ip + in_len;
72 u8 *out_end = op + out_len; 72 u8 *out_end = op + out_len;
73 73
74 const u8 *first [1 << (6+8)]; /* most recent occurance of a match */ 74 const u8 *first [1 << (6+8)]; /* most recent occurance of a match */
75 u16 prev [MAX_OFF]; /* how many bytes to go backwards for te next match */ 75 u16 prev [MAX_OFF]; /* how many bytes to go backwards for the next match */
76 76
77 int lit; 77 int lit;
78 78
79 if (!in_len || !out_len) 79 if (!in_len || !out_len)
80 return 0; 80 return 0;
114 best_l = l; 114 best_l = l;
115 } 115 }
116 } 116 }
117 117
118 diff = prev [((unsigned int)p) & (MAX_OFF - 1)]; 118 diff = prev [((unsigned int)p) & (MAX_OFF - 1)];
119 p = diff ? p - diff : (u8 *)diff; 119 p = diff ? p - diff : 0;
120 } 120 }
121 121
122 if (best_l) 122 if (best_l)
123 { 123 {
124 int len = best_l; 124 int len = best_l;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines