1 /* lzo1x_d3.c -- LZO1X decompression with preset dictionary
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer
8 The LZO library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The LZO library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the LZO library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
31 #define LZO_TEST_OVERRUN 1
34 #define SLOW_MEMCPY(a,b,l) { do *a++ = *b++; while (--l > 0); }
35 #define FAST_MEMCPY(a,b,l) { lzo_memcpy(a,b,l); a += l; }
37 #if 1 && defined(FAST_MEMCPY)
38 # define DICT_MEMMOVE(op,m_pos,m_len,m_off) \
39 if (m_off >= (m_len)) \
40 FAST_MEMCPY(op,m_pos,m_len) \
42 SLOW_MEMCPY(op,m_pos,m_len)
44 # define DICT_MEMMOVE(op,m_pos,m_len,m_off) \
45 SLOW_MEMCPY(op,m_pos,m_len)
48 #if !defined(FAST_MEMCPY)
49 # define FAST_MEMCPY SLOW_MEMCPY
53 #define COPY_DICT_DICT(m_len,m_off) \
55 const lzo_bytep m_pos; \
56 m_off -= pd(op, out); assert(m_off > 0); \
57 if (m_off > dict_len) goto lookbehind_overrun; \
58 m_pos = dict_end - m_off; \
62 FAST_MEMCPY(op,m_pos,m_off) \
64 SLOW_MEMCPY(op,m_pos,m_len) \
67 FAST_MEMCPY(op,m_pos,m_len) \
70 #define COPY_DICT(m_len,m_off) \
71 assert(m_len >= 2); assert(m_off > 0); assert(op > out); \
72 if (m_off <= pd(op, out)) \
74 const lzo_bytep m_pos = op - m_off; \
75 DICT_MEMMOVE(op,m_pos,m_len,m_off) \
78 COPY_DICT_DICT(m_len,m_off)
84 lzo1x_decompress_dict_safe ( const lzo_bytep in
, lzo_uint in_len
,
85 lzo_bytep out
, lzo_uintp out_len
,
86 lzo_voidp wrkmem
/* NOT USED */,
87 const lzo_bytep dict
, lzo_uint dict_len
)
93 /* vim:set ts=4 sw=4 et: */