[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b
Tomasz Kojm
tkojm at clamav.net
Sun Apr 4 01:09:13 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 424d41d3444238d9cd1e45a254882e7507fa3727
Author: Tomasz Kojm <tkojm at clamav.net>
Date: Mon Nov 16 19:27:35 2009 +0100
libclamav: replace qsort implementation and optimize its common usage (bb#1721)
diff --git a/ChangeLog b/ChangeLog
index 6fd6592..671addb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Nov 16 19:26:53 CET 2009 (tk)
+---------------------------------
+ * libclamav: replace qsort implementation and optimize its common
+ usage (bb#1721)
+
Tue Nov 10 19:29:18 CET 2009 (tk)
---------------------------------
* clamd, clamscan: add support for OfficialDatabaseOnly/--official-db-only
diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am
index 4a27cea..7284410 100644
--- a/libclamav/Makefile.am
+++ b/libclamav/Makefile.am
@@ -78,6 +78,7 @@ libclamav_internal_utils_la_SOURCES=str.c\
md5.h\
others_common.c \
others.h \
+ qsort.c \
regex/strlcpy.c \
regex/regcomp.c \
regex/regerror.c \
@@ -98,6 +99,7 @@ libclamav_internal_utils_nothreads_la_SOURCES=str.c\
md5.h\
others_common.c \
others.h \
+ qsort.c \
regex/strlcpy.c \
regex/regcomp.c \
regex/regerror.c \
diff --git a/libclamav/Makefile.in b/libclamav/Makefile.in
index 7d86e2c..ce952aa 100644
--- a/libclamav/Makefile.in
+++ b/libclamav/Makefile.in
@@ -210,6 +210,7 @@ am_libclamav_internal_utils_la_OBJECTS = \
libclamav_internal_utils_la-str.lo \
libclamav_internal_utils_la-md5.lo \
libclamav_internal_utils_la-others_common.lo \
+ libclamav_internal_utils_la-qsort.lo \
libclamav_internal_utils_la-strlcpy.lo \
libclamav_internal_utils_la-regcomp.lo \
libclamav_internal_utils_la-regerror.lo \
@@ -226,6 +227,7 @@ am_libclamav_internal_utils_nothreads_la_OBJECTS = \
libclamav_internal_utils_nothreads_la-str.lo \
libclamav_internal_utils_nothreads_la-md5.lo \
libclamav_internal_utils_nothreads_la-others_common.lo \
+ libclamav_internal_utils_nothreads_la-qsort.lo \
libclamav_internal_utils_nothreads_la-strlcpy.lo \
libclamav_internal_utils_nothreads_la-regcomp.lo \
libclamav_internal_utils_nothreads_la-regerror.lo \
@@ -510,6 +512,7 @@ libclamav_internal_utils_la_SOURCES = str.c\
md5.h\
others_common.c \
others.h \
+ qsort.c \
regex/strlcpy.c \
regex/regcomp.c \
regex/regerror.c \
@@ -529,6 +532,7 @@ libclamav_internal_utils_nothreads_la_SOURCES = str.c\
md5.h\
others_common.c \
others.h \
+ qsort.c \
regex/strlcpy.c \
regex/regcomp.c \
regex/regerror.c \
@@ -688,6 +692,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-md5.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-others_common.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-qsort.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-regcomp.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-regerror.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-regexec.Plo at am__quote@
@@ -696,6 +701,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_la-strlcpy.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_nothreads_la-md5.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_nothreads_la-others_common.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_nothreads_la-qsort.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_nothreads_la-regcomp.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_nothreads_la-regerror.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libclamav_internal_utils_nothreads_la-regexec.Plo at am__quote@
@@ -1615,6 +1621,14 @@ libclamav_internal_utils_la-others_common.lo: others_common.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-others_common.lo `test -f 'others_common.c' || echo '$(srcdir)/'`others_common.c
+libclamav_internal_utils_la-qsort.lo: qsort.c
+ at am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-qsort.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-qsort.Tpo -c -o libclamav_internal_utils_la-qsort.lo `test -f 'qsort.c' || echo '$(srcdir)/'`qsort.c
+ at am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-qsort.Tpo $(DEPDIR)/libclamav_internal_utils_la-qsort.Plo
+ at am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qsort.c' object='libclamav_internal_utils_la-qsort.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-qsort.lo `test -f 'qsort.c' || echo '$(srcdir)/'`qsort.c
+
libclamav_internal_utils_la-strlcpy.lo: regex/strlcpy.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-strlcpy.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-strlcpy.Tpo -c -o libclamav_internal_utils_la-strlcpy.lo `test -f 'regex/strlcpy.c' || echo '$(srcdir)/'`regex/strlcpy.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-strlcpy.Tpo $(DEPDIR)/libclamav_internal_utils_la-strlcpy.Plo
@@ -1679,6 +1693,14 @@ libclamav_internal_utils_nothreads_la-others_common.lo: others_common.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-others_common.lo `test -f 'others_common.c' || echo '$(srcdir)/'`others_common.c
+libclamav_internal_utils_nothreads_la-qsort.lo: qsort.c
+ at am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-qsort.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-qsort.Tpo -c -o libclamav_internal_utils_nothreads_la-qsort.lo `test -f 'qsort.c' || echo '$(srcdir)/'`qsort.c
+ at am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-qsort.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-qsort.Plo
+ at am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qsort.c' object='libclamav_internal_utils_nothreads_la-qsort.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-qsort.lo `test -f 'qsort.c' || echo '$(srcdir)/'`qsort.c
+
libclamav_internal_utils_nothreads_la-strlcpy.lo: regex/strlcpy.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-strlcpy.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-strlcpy.Tpo -c -o libclamav_internal_utils_nothreads_la-strlcpy.lo `test -f 'regex/strlcpy.c' || echo '$(srcdir)/'`regex/strlcpy.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-strlcpy.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-strlcpy.Plo
diff --git a/libclamav/matcher-bm.c b/libclamav/matcher-bm.c
index 5c42164..a206699 100644
--- a/libclamav/matcher-bm.c
+++ b/libclamav/matcher-bm.c
@@ -140,11 +140,6 @@ int cli_bm_init(struct cli_matcher *root)
return CL_SUCCESS;
}
-static int qcompare(const void *a, const void *b)
-{
- return *(const uint32_t *)a - *(const uint32_t *)b;
-}
-
int cli_bm_initoff(const struct cli_matcher *root, struct cli_bm_off *data, fmap_t *map)
{
int ret;
@@ -195,7 +190,7 @@ int cli_bm_initoff(const struct cli_matcher *root, struct cli_bm_off *data, fmap
if(info.exeinfo.section)
free(info.exeinfo.section);
- cli_qsort(data->offtab, data->cnt, sizeof(uint32_t), qcompare);
+ cli_qsort(data->offtab, data->cnt, sizeof(uint32_t), NULL);
return CL_SUCCESS;
}
diff --git a/libclamav/others.h b/libclamav/others.h
index 7f57866..e66db3f 100644
--- a/libclamav/others.h
+++ b/libclamav/others.h
@@ -407,7 +407,7 @@ int cli_checklimits(const char *, cli_ctx *, unsigned long, unsigned long, unsig
int cli_updatelimits(cli_ctx *, unsigned long);
unsigned long cli_getsizelimit(cli_ctx *, unsigned long);
int cli_matchregex(const char *str, const char *regex);
-void cli_qsort(void *basep, size_t nelems, size_t size, int (*comp)(const void *, const void *));
+void cli_qsort(void *a, size_t n, size_t es, int (*cmp)(const void *, const void *));
/* symlink behaviour */
#define CLI_FTW_FOLLOW_FILE_SYMLINK 0x01
diff --git a/libclamav/others_common.c b/libclamav/others_common.c
index e686964..0d7aba2 100644
--- a/libclamav/others_common.c
+++ b/libclamav/others_common.c
@@ -834,83 +834,3 @@ int cli_regcomp(regex_t *preg, const char *pattern, int cflags)
}
return cli_regcomp_real(preg, pattern, cflags);
}
-
-/* Public domain qsort implementation by Raymond Gardner and Paul Edwards */
-#define SWAP(a, b) (qsort_swap((char *)(a), (char *)(b), size))
-#define COMP(a, b) ((*comp)((void *)(a), (void *)(b)))
-#define T 7 /* subfiles of T or fewer elements will
- * be sorted by a simple insertion sort
- * T must be at least 3
- */
-
-static void qsort_swap(char *a, char *b, size_t nbytes)
-{
- char tmp;
-
- do {
- tmp = *a;
- *a++ = *b;
- *b++ = tmp;
- } while(--nbytes);
-}
-
-void cli_qsort(void *basep, size_t nelems, size_t size, int (*comp)(const void *, const void *))
-{
- char *stack[40], **sp;
- char *i, *j, *limit;
- size_t thresh;
- char *base;
-
- base = (char *) basep;
- thresh = T * size;
- sp = stack;
- limit = base + nelems * size;
- while(1) {
- if(limit - base > thresh) {
- SWAP(((((size_t) (limit - base)) / size) / 2) * size + base, base);
- i = base + size;
- j = limit - size;
- if(COMP(i, j) > 0)
- SWAP(i, j);
- if(COMP(base, j) > 0)
- SWAP(base, j);
- if(COMP(i, base) > 0)
- SWAP(i, base);
- while(1) {
- do
- i += size;
- while(COMP(i, base) < 0);
- do
- j -= size;
- while(COMP(j, base) > 0);
- if(i > j)
- break;
- SWAP(i, j);
- }
- SWAP(base, j);
- if(j - base > limit - i) {
- sp[0] = base;
- sp[1] = j;
- base = i;
- } else {
- sp[0] = i;
- sp[1] = limit;
- limit = j;
- }
- sp += 2;
- } else {
- for(j = base, i = j + size; i < limit; j = i, i += size)
- for(; COMP(j, j + size) > 0; j -= size) {
- SWAP(j, j+size);
- if(j == base)
- break;
- }
- if(sp != stack) {
- sp -= 2;
- base = sp[0];
- limit = sp[1];
- } else
- break;
- }
- }
-}
diff --git a/libclamav/qsort.c b/libclamav/qsort.c
new file mode 100644
index 0000000..a0be897
--- /dev/null
+++ b/libclamav/qsort.c
@@ -0,0 +1,164 @@
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+#include "platform.h"
+#include "cltypes.h"
+
+static inline char *med3(char *, char *, char *, int (*)(const void *, const void *));
+static inline void swapfunc(char *, char *, int, int);
+
+/*
+ * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
+ */
+#define swapcode(TYPE, parmi, parmj, n) { \
+ long i = (n) / sizeof (TYPE); \
+ register TYPE *pi = (TYPE *) (parmi); \
+ register TYPE *pj = (TYPE *) (parmj); \
+ do { \
+ register TYPE t = *pi; \
+ *pi++ = *pj; \
+ *pj++ = t; \
+ } while (--i > 0); \
+}
+
+#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
+ es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
+
+static inline void
+swapfunc(a, b, n, swaptype)
+ char *a, *b;
+ int n, swaptype;
+{
+ if(swaptype <= 1)
+ swapcode(long, a, b, n)
+ else
+ swapcode(char, a, b, n)
+}
+
+#define swap(a, b) \
+ if (swaptype == 0) { \
+ long t = *(long *)(a); \
+ *(long *)(a) = *(long *)(b); \
+ *(long *)(b) = t; \
+ } else \
+ swapfunc(a, b, es, swaptype)
+
+#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
+
+#define CMP(a, b) (cmp ? (cmp(a, b)) : ((int)(*(const uint32_t *)a - *(const uint32_t *)b)))
+
+static inline char *
+med3(a, b, c, cmp)
+ char *a, *b, *c;
+ int (*cmp)(const void *, const void *);
+{
+ return CMP(a, b) < 0 ?
+ (CMP(b, c) < 0 ? b : (CMP(a, c) < 0 ? c : a ))
+ :(CMP(b, c) > 0 ? b : (CMP(a, c) < 0 ? a : c ));
+}
+
+void cli_qsort(void *a, size_t n, size_t es, int (*cmp)(const void *, const void *))
+{
+ char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+ int d, r, swaptype, swap_cnt;
+
+loop: SWAPINIT(a, es);
+ swap_cnt = 0;
+ if (n < 7) {
+ for (pm = a + es; pm < (char *) a + n * es; pm += es)
+ for (pl = pm; pl > (char *) a && CMP(pl - es, pl) > 0;
+ pl -= es)
+ swap(pl, pl - es);
+ return;
+ }
+ pm = a + (n / 2) * es;
+ if (n > 7) {
+ pl = a;
+ pn = a + (n - 1) * es;
+ if (n > 40) {
+ d = (n / 8) * es;
+ pl = med3(pl, pl + d, pl + 2 * d, cmp);
+ pm = med3(pm - d, pm, pm + d, cmp);
+ pn = med3(pn - 2 * d, pn - d, pn, cmp);
+ }
+ pm = med3(pl, pm, pn, cmp);
+ }
+ swap(a, pm);
+ pa = pb = a + es;
+
+ pc = pd = a + (n - 1) * es;
+ for (;;) {
+ while (pb <= pc && (r = CMP(pb, a)) <= 0) {
+ if (r == 0) {
+ swap_cnt = 1;
+ swap(pa, pb);
+ pa += es;
+ }
+ pb += es;
+ }
+ while (pb <= pc && (r = CMP(pc, a)) >= 0) {
+ if (r == 0) {
+ swap_cnt = 1;
+ swap(pc, pd);
+ pd -= es;
+ }
+ pc -= es;
+ }
+ if (pb > pc)
+ break;
+ swap(pb, pc);
+ swap_cnt = 1;
+ pb += es;
+ pc -= es;
+ }
+ if (swap_cnt == 0) { /* Switch to insertion sort */
+ for (pm = a + es; pm < (char *) a + n * es; pm += es)
+ for (pl = pm; pl > (char *) a && CMP(pl - es, pl) > 0;
+ pl -= es)
+ swap(pl, pl - es);
+ return;
+ }
+
+ pn = a + n * es;
+ r = MIN(pa - (char *)a, pb - pa);
+ vecswap(a, pb - r, r);
+ r = MIN(pd - pc, pn - pd - es);
+ vecswap(pb, pn - r, r);
+ if ((r = pb - pa) > es)
+ cli_qsort(a, r / es, es, cmp);
+ if ((r = pd - pc) > es) {
+ /* Iterate rather than recurse to save stack space */
+ a = pn - r;
+ n = r / es;
+ goto loop;
+ }
+/* cli_qsort(pn - r, r / es, es, cmp);*/
+}
diff --git a/libclamav/readdb.c b/libclamav/readdb.c
index 04721ca..a4790e2 100644
--- a/libclamav/readdb.c
+++ b/libclamav/readdb.c
@@ -1238,11 +1238,6 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options,
return CL_SUCCESS;
}
-static int scomp(const void *a, const void *b)
-{
- return *(const uint32_t *)a - *(const uint32_t *)b;
-}
-
#define MD5_HDB 0
#define MD5_MDB 1
#define MD5_FP 2
@@ -2211,7 +2206,7 @@ static void cli_md5db_build(struct cli_matcher* root)
root->soff_len = cli_hashset_toarray(&root->md5_sizes_hs, &root->soff);
#endif
cli_hashset_destroy(&root->md5_sizes_hs);
- cli_qsort(root->soff, root->soff_len, sizeof(uint32_t), scomp);
+ cli_qsort(root->soff, root->soff_len, sizeof(uint32_t), NULL);
}
}
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list