summaryrefslogtreecommitdiff
path: root/src/lzo1a.c
diff options
context:
space:
mode:
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-12-23 14:06:25 +0100
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-12-23 14:06:25 +0100
commit79a9578a33ecd3093970bd18df677edc9214fafb (patch)
tree8ae5c6780a1fcd2124e71f27ad9b4256acd24268 /src/lzo1a.c
parent1bb1ce141783168d44a38cd1bb6b822eb13114fc (diff)
downloadlzo-79a9578a33ecd3093970bd18df677edc9214fafb.tar.gz
lzo-79a9578a33ecd3093970bd18df677edc9214fafb.tar.bz2
lzo-79a9578a33ecd3093970bd18df677edc9214fafb.zip
Imported Upstream version 2.08upstream/2.08sandbox/kevinthierry/upstream
Diffstat (limited to 'src/lzo1a.c')
-rw-r--r--src/lzo1a.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/src/lzo1a.c b/src/lzo1a.c
index c571359..e0894f6 100644
--- a/src/lzo1a.c
+++ b/src/lzo1a.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -63,7 +51,7 @@
/* Collect statistics */
#if 0 && !defined(LZO_COLLECT_STATS)
-# define LZO_COLLECT_STATS
+# define LZO_COLLECT_STATS 1
#endif
@@ -102,7 +90,7 @@
#endif
-#if defined(LZO_COLLECT_STATS)
+#if (LZO_COLLECT_STATS)
static lzo1a_stats_t lzo_statistics;
lzo1a_stats_t *lzo1a_stats = &lzo_statistics;
# define lzo_stats lzo1a_stats
@@ -137,10 +125,10 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem )
{
- register lzo_bytep op;
- register const lzo_bytep ip;
- register lzo_uint t;
- register const lzo_bytep m_pos;
+ lzo_bytep op;
+ const lzo_bytep ip;
+ lzo_uint t;
+ const lzo_bytep m_pos;
const lzo_bytep const ip_end = in + in_len;
LZO_UNUSED(wrkmem);
@@ -194,9 +182,9 @@ literal:
m_pos = op - MIN_OFFSET;
m_pos -= t | (((lzo_uint) *ip++) << OBITS);
assert(m_pos >= out); assert(m_pos < op);
- *op++ = *m_pos++;
- *op++ = *m_pos++;
- *op++ = *m_pos++;
+ *op++ = m_pos[0];
+ *op++ = m_pos[1];
+ *op++ = m_pos[2];
*op++ = *ip++;
}
}
@@ -259,7 +247,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem )
{
- register const lzo_bytep ip;
+ const lzo_bytep ip;
#if defined(__LZO_HASH_INCREMENTAL)
lzo_xint dv;
#endif
@@ -283,7 +271,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
ii = ip; /* point to start of current literal run */
/* init dictionary */
-#if defined(LZO_DETERMINISTIC)
+#if (LZO_DETERMINISTIC)
BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
#endif
@@ -291,7 +279,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
DVAL_NEXT(dv,ip);
do {
- lzo_uint m_off;
+ LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
lzo_uint dindex;
DINDEX1(dindex,ip);
@@ -316,7 +304,7 @@ literal:
match:
UPDATE_I(dict,0,dindex,ip,in);
-#if !defined(NDEBUG) && defined(LZO_DICT_USE_PTR)
+#if !defined(NDEBUG) && (LZO_DICT_USE_PTR)
assert(m_pos == NULL || m_pos >= in);
m_pos_sav = m_pos;
#endif
@@ -324,7 +312,7 @@ match:
{
/* we have found a match (of at least length 3) */
-#if !defined(NDEBUG) && !defined(LZO_DICT_USE_PTR)
+#if !defined(NDEBUG) && !(LZO_DICT_USE_PTR)
assert((m_pos_sav = ip - m_off) == (m_pos - 3));
#endif
@@ -371,7 +359,7 @@ match:
LZO_STATS(lzo_stats->lit_run_after_long_match[t]++);
assert(ii - im <= MAX_MATCH_LONG);
assert((op[-1] >> LBITS) == 0);
- op[-1] |= t << LBITS;
+ op[-1] = LZO_BYTE(op[-1] | (t << LBITS));
MEMCPY_DS(op, ii, t);
}
else
@@ -452,7 +440,7 @@ match:
*op++ = LZO_BYTE(m_off >> OBITS);
-#if defined(LZO_COLLECT_STATS)
+#if (LZO_COLLECT_STATS)
lzo_stats->short_matches++;
lzo_stats->short_match[m_len]++;
if (m_off < OSIZE)
@@ -530,7 +518,7 @@ match:
*op++ = LZO_BYTE(m_len - MIN_MATCH_LONG);
-#if defined(LZO_COLLECT_STATS)
+#if (LZO_COLLECT_STATS)
lzo_stats->long_matches++;
lzo_stats->long_match[m_len]++;
#endif
@@ -608,7 +596,7 @@ lzo1a_compress ( const lzo_bytep in , lzo_uint in_len,
int r = LZO_E_OK;
-#if defined(LZO_COLLECT_STATS)
+#if (LZO_COLLECT_STATS)
lzo_memset(lzo_stats,0,sizeof(*lzo_stats));
lzo_stats->rbits = RBITS;
lzo_stats->clevel = CLEVEL;
@@ -628,7 +616,7 @@ lzo1a_compress ( const lzo_bytep in , lzo_uint in_len,
/* don't try to compress a block that's too short */
- if (in_len <= 0)
+ if (in_len == 0)
*out_len = 0;
else if (in_len <= MIN_MATCH_LONG + DVAL_LEN + 1)
{
@@ -642,7 +630,7 @@ lzo1a_compress ( const lzo_bytep in , lzo_uint in_len,
r = do_compress(in,in_len,out,out_len,wrkmem);
-#if defined(LZO_COLLECT_STATS)
+#if (LZO_COLLECT_STATS)
lzo_stats->short_matches -= lzo_stats->r1_matches;
lzo_stats->short_match[MIN_MATCH] -= lzo_stats->r1_matches;
lzo_stats->out_len = *out_len;