Refactor pubkey destructor to eliinate Unlink() helper
- Having a helper function to decrement an integer seems a bit much, but mostly this is preparing for thread protection where the unlink-helpers would just get in the way.
This commit is contained in:
parent
4c7ee7383a
commit
20a79a7ac7
|
@ -25,8 +25,6 @@ struct rpmKeyring_s {
|
|||
int nrefs;
|
||||
};
|
||||
|
||||
static rpmPubkey rpmPubkeyUnlink(rpmPubkey key);
|
||||
|
||||
static int keyidcmp(const void *k1, const void *k2)
|
||||
{
|
||||
const struct rpmPubkey_s *key1 = *(const struct rpmPubkey_s **) k1;
|
||||
|
@ -142,12 +140,11 @@ rpmPubkey rpmPubkeyFree(rpmPubkey key)
|
|||
if (key == NULL)
|
||||
return NULL;
|
||||
|
||||
if (key->nrefs > 1)
|
||||
return rpmPubkeyUnlink(key);
|
||||
|
||||
pgpDigParamsFree(key->pgpkey);
|
||||
free(key->pkt);
|
||||
free(key);
|
||||
if (--key->nrefs == 0) {
|
||||
pgpDigParamsFree(key->pgpkey);
|
||||
free(key->pkt);
|
||||
free(key);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -159,14 +156,6 @@ rpmPubkey rpmPubkeyLink(rpmPubkey key)
|
|||
return key;
|
||||
}
|
||||
|
||||
static rpmPubkey rpmPubkeyUnlink(rpmPubkey key)
|
||||
{
|
||||
if (key) {
|
||||
key->nrefs--;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pgpDig rpmPubkeyDig(rpmPubkey key)
|
||||
{
|
||||
pgpDig dig = NULL;
|
||||
|
|
Loading…
Reference in New Issue