]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - mem.c
Fold in some of dsilvers' autoconf changes.
[onak.git] / mem.c
diff --git a/mem.c b/mem.c
index 1b9627cc145da0a1253295202e3580c5cb1a936f..83ffa55375e5713477d4d68dacadf59a6d5e73e0 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -9,6 +9,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "keystructs.h"
 #include "ll.h"
 
 #include "keystructs.h"
 #include "ll.h"
@@ -171,3 +172,26 @@ void free_publickey(struct openpgp_publickey *key) {
                key = nextkey;
        }
 }
                key = nextkey;
        }
 }
+
+/**
+ *     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.
+ */
+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);
+       }
+}