[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

Török Edvin edwin at clamav.net
Sun Apr 4 01:13:22 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 6f1d98ebaf870bccd805c383ddad776b3df04218
Author: Török Edvin <edwin at clamav.net>
Date:   Mon Jan 4 17:08:59 2010 +0200

    add _noalloc hashset functions requested by aCaB.
    
    This allows to bzero the hashset struct, and make key lookups on it
    (they'll all return false) without actually allocating any memory.
    When you really want to add some keys, you _init and _addkey/_removekey as
    usual which will allocate memory.

diff --git a/libclamav/hashtab.c b/libclamav/hashtab.c
index c5f899e..e4c629e 100644
--- a/libclamav/hashtab.c
+++ b/libclamav/hashtab.c
@@ -555,3 +555,15 @@ ssize_t cli_hashset_toarray(const struct cli_hashset* hs, uint32_t** array)
 	}
 	return j;
 }
+
+void cli_hashset_init_noalloc(struct cli_hashset *hs)
+{
+    memset(hs, 0, sizeof(hs));
+}
+
+int cli_hashset_contains_maybe_noalloc(const struct cli_hashset *hs, const uint32_t key)
+{
+    if (!hs->keys)
+	return 0;
+    return cli_hashset_contains(hs, key);
+}
diff --git a/libclamav/hashtab.h b/libclamav/hashtab.h
index d06858d..d9ef62f 100644
--- a/libclamav/hashtab.h
+++ b/libclamav/hashtab.h
@@ -103,5 +103,13 @@ int cli_hashset_contains(const struct cli_hashset* hs, const uint32_t key);
 int cli_hashset_clear(struct cli_hashset* hs);
 void cli_hashset_destroy(struct cli_hashset* hs);
 ssize_t cli_hashset_toarray(const struct cli_hashset* hs, uint32_t** array);
+
+/* Initializes the set without allocating memory, you can do lookups on it
+ * using _contains_maybe_noalloc. You need to initialize it using _init
+ * before using _addkey or _removekey though */
+void cli_hashset_init_noalloc(struct cli_hashset *hs);
+/* this works like its _contains counterpart above, except that the hashset may
+ * have not been initialized by _init, only by _init_noalloc */
+int cli_hashset_contains_maybe_noalloc(const struct cli_hashset *hs, const uint32_t key);
 #endif
 

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list