Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nemequ/liblzf.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Lehmann <schmorpforge@schmorp.de>2015-02-24 02:46:10 +0300
committerMarc Lehmann <schmorpforge@schmorp.de>2015-02-24 02:46:10 +0300
commit7eba614039082b930d282684355a53bf25733df6 (patch)
tree7fec010340e569a8bf90ab5e1ba16542912e01be
parentd71a793968b0dcaaa71eeae25165685aa98f522a (diff)
*** empty log message ***
-rw-r--r--lzfP.h13
-rw-r--r--lzf_d.c13
2 files changed, 24 insertions, 2 deletions
diff --git a/lzfP.h b/lzfP.h
index 1ed373e..2d1a8f9 100644
--- a/lzfP.h
+++ b/lzfP.h
@@ -146,6 +146,19 @@
*/
/*#define LZF_USE_OFFSETS autodetect */
+/*
+ * Whether to optimise code for size, at the expense of speed. Use
+ * this when you are extremely tight on memory, perhaps in combination
+ * with AVOID_ERRNO 1 and CHECK_INPUT 0.
+ */
+#ifndef OPTIMISE_SIZE
+# ifdef __OPTIMIZE_SIZE__
+# define OPTIMISE_SIZE 1
+# else
+# define OPTIMISE_SIZE 0
+# endif
+#endif
+
/*****************************************************************************/
/* nothing should be changed below */
diff --git a/lzf_d.c b/lzf_d.c
index ad2f730..91b21f0 100644
--- a/lzf_d.c
+++ b/lzf_d.c
@@ -52,7 +52,7 @@
#endif
#endif
-unsigned int
+unsigned int
lzf_decompress (const void *const in_data, unsigned int in_len,
void *out_data, unsigned int out_len)
{
@@ -85,6 +85,9 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
#ifdef lzf_movsb
lzf_movsb (op, ip, ctrl);
+#elif OPTIMISE_SIZE
+ while (ctrl--)
+ *op++ = *ip++;
#else
switch (ctrl)
{
@@ -141,6 +144,12 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
#ifdef lzf_movsb
len += 2;
lzf_movsb (op, ref, len);
+#elif OPTIMISE_SIZE
+ len += 2;
+
+ do
+ *op++ = *ref++;
+ while (--len);
#else
switch (len)
{
@@ -155,7 +164,7 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
}
else
{
- /* overlapping, use octte by octte copying */
+ /* overlapping, use octet by octet copying */
do
*op++ = *ref++;
while (--len);