added pcphash_cleanpub() to free local pubkey hashes, which are not attached to any context

This commit is contained in:
TLINDEN
2014-08-07 21:32:48 +02:00
parent 3778b3f44e
commit e8f6a8635c
2 changed files with 12 additions and 1 deletions

View File

@@ -88,9 +88,12 @@
*/ */
void pcphash_del(PCPCTX *ptx, void *key, int type); void pcphash_del(PCPCTX *ptx, void *key, int type);
/** Free memory used by key hashes. */ /** Free memory used by key global ptx-attached hashes. */
void pcphash_clean(PCPCTX *ptx); void pcphash_clean(PCPCTX *ptx);
/** Free memory by local pubkey hash */
void pcphash_cleanpub(pcp_pubkey_t *pub);
/** Check if a secret key with a given key-id exists in the hash. /** Check if a secret key with a given key-id exists in the hash.
\param[in] PCP Context object. \param[in] PCP Context object.

View File

@@ -64,6 +64,14 @@ void pcphash_clean(PCPCTX *ptx) {
} }
} }
void pcphash_cleanpub(pcp_pubkey_t *pub) {
pcp_pubkey_t *current_pub, *ptmp;
HASH_ITER(hh, pub, current_pub, ptmp) {
HASH_DEL(pub, (pcp_pubkey_t *)current_pub);
memset(current_pub, 0, sizeof(pcp_pubkey_t));
free(current_pub);
}
}
pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id) { pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id) {
pcp_keysig_t *keysig = NULL; pcp_keysig_t *keysig = NULL;