X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=hash.c;h=9357831ccc9b352fd3531f8afc4ebaf54df58700;hp=62be39403cea96d40d84255a6f1af1aae680a3c9;hb=58ed9a0076feb9604154b99da6ed1907ca7df089;hpb=6df51fef2960f533a741fb7290867387ed3fbba5 diff --git a/hash.c b/hash.c index 62be394..9357831 100644 --- a/hash.c +++ b/hash.c @@ -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); }