From: Jonathan McDowell Date: Tue, 9 Apr 2019 14:42:28 +0000 (+0100) Subject: Move free_statskey into hash.c X-Git-Tag: onak-0.6.0~69 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=63024252ef5bc13b0b920112b91c1945e0cc6f13;p=onak.git Move free_statskey into hash.c free_statskey() is only used within hash.c, so move it out of mem.c and scope it more narrowly. --- 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); } diff --git a/mem.c b/mem.c index 8632bc2..6ac80e6 100644 --- a/mem.c +++ b/mem.c @@ -172,26 +172,3 @@ void free_publickey(struct openpgp_publickey *key) { 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); - } -} diff --git a/mem.h b/mem.h index b53a88b..88086d4 100644 --- a/mem.h +++ b/mem.h @@ -84,14 +84,4 @@ void free_signedpacket_list( */ void free_publickey(struct openpgp_publickey *key); -/** - * 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); - #endif /* __MEM_H_ */