Add missing function.

0.96
Török Edvin 16 years ago
parent 7f6b55a124
commit ded1cddc8c
  1. 3
      libclamav/bytecode_api.c
  2. 12
      libclamav/hashtab.c
  3. 1
      libclamav/hashtab.h

@ -504,8 +504,7 @@ int32_t cli_bcapi_hashset_remove(struct cli_bc_ctx *ctx , int32_t id, uint32_t k
struct cli_hashset *s = get_hashset(ctx, id);
if (!s)
return -1;
// return cli_hashset_removekey(s, key);
return -1;
return cli_hashset_removekey(s, key);
}
int32_t cli_bcapi_hashset_contains(struct cli_bc_ctx *ctx , int32_t id, uint32_t key)

@ -453,6 +453,7 @@ void cli_hashset_destroy(struct cli_hashset* hs)
#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & (1 << ((val) & 0x1f)))
#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= (1 << ((val) & 0x1f)))
#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~(1 << ((val) & 0x1f)))
/*
* searches the hashset for the @key.
@ -475,7 +476,6 @@ static inline size_t cli_hashset_search(const struct cli_hashset* hs, const uint
return idx;
}
static void cli_hashset_addkey_internal(struct cli_hashset* hs, const uint32_t key)
{
const size_t idx = cli_hashset_search(hs, key);
@ -529,6 +529,16 @@ int cli_hashset_addkey(struct cli_hashset* hs, const uint32_t key)
return 0;
}
int cli_hashset_removekey(struct cli_hashset* hs, const uint32_t key)
{
const size_t idx = cli_hashset_search(hs, key);
if (BITMAP_CONTAINS(hs->bitmap, idx)) {
BITMAP_REMOVE(hs->bitmap, idx);
hs->keys[idx] = 0;
hs->count--;
}
}
int cli_hashset_contains(const struct cli_hashset* hs, const uint32_t key)
{
const size_t idx = cli_hashset_search(hs, key);

@ -104,6 +104,7 @@ 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);
int cli_hashset_removekey(struct cli_hashset* hs, const uint32_t key);
/* Initializes the set without allocating memory, you can do lookups on it
* using _contains_maybe_noalloc. You need to initialize it using _init

Loading…
Cancel
Save