(_hx509_revoke_ref): new function.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22214 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-12-08 07:35:17 +00:00
parent 9909c7edb1
commit 4dcc33a770

View File

@@ -52,6 +52,7 @@ struct revoke_ocsp {
struct hx509_revoke_ctx_data {
unsigned ref;
struct {
struct revoke_crl *val;
size_t len;
@@ -69,6 +70,7 @@ hx509_revoke_init(hx509_context context, hx509_revoke_ctx *ctx)
if (*ctx == NULL)
return ENOMEM;
(*ctx)->ref = 1;
(*ctx)->crls.len = 0;
(*ctx)->crls.val = NULL;
(*ctx)->ocsps.len = 0;
@@ -77,6 +79,17 @@ hx509_revoke_init(hx509_context context, hx509_revoke_ctx *ctx)
return 0;
}
hx509_revoke_ctx
_hx509_revoke_ref(hx509_revoke_ctx ctx)
{
if (ctx->ref <= 0)
_hx509_abort("revoke ctx refcount <= 0");
ctx->ref++;
if (ctx->ref == 0)
_hx509_abort("revoke ctx refcount == 0");
return ctx;
}
static void
free_ocsp(struct revoke_ocsp *ocsp)
{
@@ -94,6 +107,11 @@ hx509_revoke_free(hx509_revoke_ctx *ctx)
if (ctx == NULL || *ctx == NULL)
return;
if ((*ctx)->ref <= 0)
_hx509_abort("revoke ctx refcount <= 0 on free");
if (--(*ctx)->ref > 0)
return;
for (i = 0; i < (*ctx)->crls.len; i++) {
free((*ctx)->crls.val[i].path);
free_CRLCertificateList(&(*ctx)->crls.val[i].crl);