]> the.earth.li Git - onak.git/blobdiff - hash.c
Fix handling of other signature requirement
[onak.git] / hash.c
diff --git a/hash.c b/hash.c
index 49443ed07093ded1c6a80d017fe46284ca481ed5..9357831ccc9b352fd3531f8afc4ebaf54df58700 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -13,8 +13,7 @@
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <stdio.h>
@@ -25,6 +24,7 @@
 #include "keystructs.h"
 #include "ll.h"
 #include "mem.h"
+#include "stats.h"
 
 /**
  *     hashtable - the hash table array.
@@ -36,6 +36,29 @@ static struct ll *hashtable[HASHSIZE];
  */
 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.
  */
@@ -110,7 +133,7 @@ struct stats_key *createandaddtohash(uint64_t keyid)
        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);
 }