Blame src/lzo1x_d3.c

Packit 679830
/* lzo1x_d3.c -- LZO1X decompression with preset dictionary
Packit 679830
Packit 679830
   This file is part of the LZO real-time data compression library.
Packit 679830
Packit 679830
   Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
Packit 679830
   All Rights Reserved.
Packit 679830
Packit 679830
   The LZO library is free software; you can redistribute it and/or
Packit 679830
   modify it under the terms of the GNU General Public License as
Packit 679830
   published by the Free Software Foundation; either version 2 of
Packit 679830
   the License, or (at your option) any later version.
Packit 679830
Packit 679830
   The LZO library is distributed in the hope that it will be useful,
Packit 679830
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 679830
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 679830
   GNU General Public License for more details.
Packit 679830
Packit 679830
   You should have received a copy of the GNU General Public License
Packit 679830
   along with the LZO library; see the file COPYING.
Packit 679830
   If not, write to the Free Software Foundation, Inc.,
Packit 679830
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 679830
Packit 679830
   Markus F.X.J. Oberhumer
Packit 679830
   <markus@oberhumer.com>
Packit 679830
   http://www.oberhumer.com/opensource/lzo/
Packit 679830
 */
Packit 679830
Packit 679830
Packit 679830
#include "config1x.h"
Packit 679830
Packit 679830
#define LZO_TEST_OVERRUN 1
Packit 679830
Packit 679830
Packit 679830
#define SLOW_MEMCPY(a,b,l)      { do *a++ = *b++; while (--l > 0); }
Packit 679830
#define FAST_MEMCPY(a,b,l)      { lzo_memcpy(a,b,l); a += l; }
Packit 679830
Packit 679830
#if 1 && defined(FAST_MEMCPY)
Packit 679830
#  define DICT_MEMMOVE(op,m_pos,m_len,m_off) \
Packit 679830
        if (m_off >= (m_len)) \
Packit 679830
            FAST_MEMCPY(op,m_pos,m_len) \
Packit 679830
        else \
Packit 679830
            SLOW_MEMCPY(op,m_pos,m_len)
Packit 679830
#else
Packit 679830
#  define DICT_MEMMOVE(op,m_pos,m_len,m_off) \
Packit 679830
        SLOW_MEMCPY(op,m_pos,m_len)
Packit 679830
#endif
Packit 679830
Packit 679830
#if !defined(FAST_MEMCPY)
Packit 679830
#  define FAST_MEMCPY   SLOW_MEMCPY
Packit 679830
#endif
Packit 679830
Packit 679830
Packit 679830
#define COPY_DICT_DICT(m_len,m_off) \
Packit 679830
    { \
Packit 679830
        const lzo_bytep m_pos; \
Packit 679830
        m_off -= pd(op, out); assert(m_off > 0); \
Packit 679830
        if (m_off > dict_len) goto lookbehind_overrun; \
Packit 679830
        m_pos = dict_end - m_off; \
Packit 679830
        if (m_len > m_off) \
Packit 679830
        { \
Packit 679830
            m_len -= m_off; \
Packit 679830
            FAST_MEMCPY(op,m_pos,m_off) \
Packit 679830
            m_pos = out; \
Packit 679830
            SLOW_MEMCPY(op,m_pos,m_len) \
Packit 679830
        } \
Packit 679830
        else \
Packit 679830
            FAST_MEMCPY(op,m_pos,m_len) \
Packit 679830
    }
Packit 679830
Packit 679830
#define COPY_DICT(m_len,m_off) \
Packit 679830
    assert(m_len >= 2); assert(m_off > 0); assert(op > out); \
Packit 679830
    if (m_off <= pd(op, out)) \
Packit 679830
    { \
Packit 679830
        const lzo_bytep m_pos = op - m_off; \
Packit 679830
        DICT_MEMMOVE(op,m_pos,m_len,m_off) \
Packit 679830
    } \
Packit 679830
    else \
Packit 679830
        COPY_DICT_DICT(m_len,m_off)
Packit 679830
Packit 679830
Packit 679830
Packit 679830
Packit 679830
LZO_PUBLIC(int)
Packit 679830
lzo1x_decompress_dict_safe ( const lzo_bytep in,  lzo_uint  in_len,
Packit 679830
                                   lzo_bytep out, lzo_uintp out_len,
Packit 679830
                                   lzo_voidp wrkmem /* NOT USED */,
Packit 679830
                             const lzo_bytep dict, lzo_uint dict_len)
Packit 679830
Packit 679830
Packit 679830
#include "lzo1x_d.ch"
Packit 679830
Packit 679830
Packit 679830
/*
Packit 679830
vi:ts=4:et
Packit 679830
*/
Packit 679830