Coverage Report

Created: 2023-09-25 06:16

/src/lzo-2.10/src/lzo1_99.c
Line
Count
Source (jump to first uncovered line)
1
/* lzo1_99.c -- implementation of the LZO1-99 algorithm
2
3
   This file is part of the LZO real-time data compression library.
4
5
   Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
6
   All Rights Reserved.
7
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.
12
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.
17
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.
22
23
   Markus F.X.J. Oberhumer
24
   <markus@oberhumer.com>
25
   http://www.oberhumer.com/opensource/lzo/
26
 */
27
28
29
30
#define COMPRESS_ID     99
31
32
13.1M
#define DDBITS          3
33
#define CLEVEL          9
34
35
36
/***********************************************************************
37
//
38
************************************************************************/
39
40
#define LZO_NEED_DICT_H 1
41
#include "config1.h"
42
43
44
/***********************************************************************
45
// compression internal entry point.
46
************************************************************************/
47
48
static int
49
_lzo1_do_compress ( const lzo_bytep in,  lzo_uint  in_len,
50
                          lzo_bytep out, lzo_uintp out_len,
51
                          lzo_voidp wrkmem,
52
                          lzo_compress_t func )
53
427
{
54
427
    int r;
55
56
    /* don't try to compress a block that's too short */
57
427
    if (in_len == 0)
58
1
    {
59
1
        *out_len = 0;
60
1
        r = LZO_E_OK;
61
1
    }
62
426
    else if (in_len <= MIN_LOOKAHEAD + 1)
63
7
    {
64
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
65
        *out_len = 0;
66
        r = LZO_E_NOT_COMPRESSIBLE;
67
#else
68
7
        *out_len = pd(STORE_RUN(out,in,in_len), out);
69
7
        r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
70
7
#endif
71
7
    }
72
419
    else
73
419
        r = func(in,in_len,out,out_len,wrkmem);
74
75
427
    return r;
76
427
}
77
78
79
/***********************************************************************
80
//
81
************************************************************************/
82
83
#if !defined(COMPRESS_ID)
84
#define COMPRESS_ID     _LZO_ECONCAT2(DD_BITS,CLEVEL)
85
#endif
86
87
88
#define LZO_CODE_MATCH_INCLUDE_FILE     "lzo1_cm.ch"
89
#include "lzo1b_c.ch"
90
91
92
/***********************************************************************
93
//
94
************************************************************************/
95
96
#define LZO_COMPRESS \
97
    LZO_PP_ECONCAT3(lzo1_,COMPRESS_ID,_compress)
98
99
#define LZO_COMPRESS_FUNC \
100
    LZO_PP_ECONCAT3(_lzo1_,COMPRESS_ID,_compress_func)
101
102
103
/***********************************************************************
104
//
105
************************************************************************/
106
107
LZO_PUBLIC(int)
108
LZO_COMPRESS ( const lzo_bytep in,  lzo_uint  in_len,
109
                     lzo_bytep out, lzo_uintp out_len,
110
                     lzo_voidp wrkmem )
111
427
{
112
427
    return _lzo1_do_compress(in,in_len,out,out_len,wrkmem,do_compress);
113
427
}
114
115
116
/* vim:set ts=4 sw=4 et: */