/*
* hash.c - hashing routines mainly used for caching key details.
*
- * Jonathan McDowell <noodles@earth.li>
+ * Copyright 2000-2002 Jonathan McDowell <noodles@earth.li>
*
- * Copyright 2000-2002 Project Purple
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
*
- * $Id: hash.c,v 1.10 2003/10/11 21:52:18 noodles Exp $
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "keystructs.h"
#include "ll.h"
#include "mem.h"
+#include "stats.h"
/**
* hashtable - the hash table array.
*/
static unsigned long elements;
+/**
+ * free_statskey - free an stats key structure.
+ * @key: The key to free.
+ *
+ * Takes a stats key and frees the memory used by it and the linked list
+ * of sigs under it. Doesn't recurse into the list as it's assumed all the
+ * objects referenced also exist in the hash.
+ */
+static void free_statskey(struct stats_key *key)
+{
+ if (key != NULL) {
+ if (key->sigs != NULL) {
+ llfree(key->sigs, NULL);
+ key->sigs = NULL;
+ }
+ if (key->signs != NULL) {
+ llfree(key->signs, NULL);
+ key->signs = NULL;
+ }
+ free(key);
+ }
+}
+
/**
* inithash - Initialize the hash ready for use.
*/
return tmpkey;
}
-int stats_key_cmp(struct stats_key *key, uint64_t *keyid)
+static int stats_key_cmp(struct stats_key *key, uint64_t *keyid)
{
return !(key != NULL && key->keyid == *keyid);
}