summaryrefslogtreecommitdiff
path: root/src/lzo1f_1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lzo1f_1.c')
-rw-r--r--src/lzo1f_1.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/src/lzo1f_1.c b/src/lzo1f_1.c
index 27608ce..0f8612e 100644
--- a/src/lzo1f_1.c
+++ b/src/lzo1f_1.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
@@ -69,7 +57,7 @@ int 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;
lzo_bytep op;
const lzo_bytep const in_end = in + in_len;
const lzo_bytep const ip_end = in + in_len - 9;
@@ -83,8 +71,8 @@ int do_compress ( const lzo_bytep in , lzo_uint in_len,
ip++;
for (;;)
{
- register const lzo_bytep m_pos;
- lzo_uint m_off;
+ const lzo_bytep m_pos;
+ LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
lzo_uint m_len;
lzo_uint dindex;
lzo_uint lit;
@@ -107,8 +95,8 @@ int do_compress ( const lzo_bytep in , lzo_uint in_len,
try_match:
-#if 0 && defined(LZO_UNALIGNED_OK_2)
- if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip)
+#if 0 && (LZO_OPT_UNALIGNED16)
+ if (UA_GET_NE16(m_pos) != UA_GET_NE16(ip))
#else
if (m_pos[0] != ip[0] || m_pos[1] != ip[1])
#endif
@@ -152,21 +140,22 @@ match:
lit = pd(ip,ii);
if (lit > 0)
{
- register lzo_uint t = lit;
+ lzo_uint t = lit;
if (t < 4 && op > out)
- op[-2] |= LZO_BYTE(t);
+ op[-2] = LZO_BYTE(op[-2] | t);
else if (t <= 31)
*op++ = LZO_BYTE(t);
else
{
- register lzo_uint tt = t - 31;
+ lzo_uint tt = t - 31;
*op++ = 0;
while (tt > 255)
{
tt -= 255;
- *op++ = 0;
+ UA_SET1(op, 0);
+ op++;
}
assert(tt > 0);
*op++ = LZO_BYTE(tt);
@@ -225,7 +214,8 @@ match:
while (m_len > 255)
{
m_len -= 255;
- *op++ = 0;
+ UA_SET1(op, 0);
+ op++;
}
assert(m_len > 0);
*op++ = LZO_BYTE(m_len);
@@ -243,26 +233,28 @@ match:
/* store final literal run */
if (pd(in_end,ii) > 0)
{
- register lzo_uint t = pd(in_end,ii);
+ lzo_uint t = pd(in_end,ii);
if (t < 4 && op > out)
- op[-2] |= LZO_BYTE(t);
+ op[-2] = LZO_BYTE(op[-2] | t);
else if (t <= 31)
*op++ = LZO_BYTE(t);
else
{
- register lzo_uint tt = t - 31;
+ lzo_uint tt = t - 31;
*op++ = 0;
while (tt > 255)
{
tt -= 255;
- *op++ = 0;
+ UA_SET1(op, 0);
+ op++;
}
assert(tt > 0);
*op++ = LZO_BYTE(tt);
}
- do *op++ = *ii++; while (--t > 0);
+ UA_COPYN(op, ii, t);
+ op += t;
}
*out_len = pd(op, out);
@@ -282,7 +274,7 @@ lzo1f_1_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_bytep op = out;
int r = LZO_E_OK;
- if (in_len <= 0)
+ if (in_len == 0)
*out_len = 0;
else if (in_len <= 10)
{
@@ -296,9 +288,9 @@ lzo1f_1_compress ( const lzo_bytep in , lzo_uint in_len,
if (r == LZO_E_OK)
{
op = out + *out_len;
- *op++ = M3_MARKER | 1;
- *op++ = 0;
- *op++ = 0;
+ op[0] = M3_MARKER | 1;
+ op[1] = 0;
+ op[2] = 0;
*out_len += 3;
}