aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpgme.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2009-06-15 17:05:47 +0000
committerMarcus Brinkmann <[email protected]>2009-06-15 17:05:47 +0000
commit59eecf421e42cb929794f31e6387dbfb5b6a543b (patch)
tree6cd59c2639f6a81fb1a998b871b571a21e23fc27 /src/gpgme.c
parentImproved W32 SetForegroundWindow hacks. (diff)
downloadgpgme-59eecf421e42cb929794f31e6387dbfb5b6a543b.tar.gz
gpgme-59eecf421e42cb929794f31e6387dbfb5b6a543b.zip
2009-06-15 Marcus Brinkmann <[email protected]>
* gpgme.h.in (gpgme_result_ref, gpgme_result_unref): Add prototypes. * gpgme.def, libgpgme.vers (gpgme_result_ref, gpgme_result_unref): Add these. * context.h (struct ctx_op_data): Add member "references". * gpgme.c (gpgme_result_ref, gpgme_result_unref): New functions. (_gpgme_release_result): Use gpgme_result_unref. * op-support.c (_gpgme_op_data_lookup): Initialize references.
Diffstat (limited to '')
-rw-r--r--src/gpgme.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/gpgme.c b/src/gpgme.c
index 203cd711..2372a06a 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -176,6 +176,35 @@ gpgme_release (gpgme_ctx_t ctx)
void
+gpgme_result_ref (void *result)
+{
+ struct ctx_op_data *data = result - sizeof (struct ctx_op_data);
+
+ if (! result)
+ return;
+
+ data->references++;
+}
+
+
+void
+gpgme_result_unref (void *result)
+{
+ struct ctx_op_data *data = result - sizeof (struct ctx_op_data);
+
+ if (! result)
+ return;
+
+ if (--data->references == 0)
+ {
+ if (data->cleanup)
+ (*data->cleanup) (data->hook);
+ free (data);
+ }
+}
+
+
+void
_gpgme_release_result (gpgme_ctx_t ctx)
{
struct ctx_op_data *data = ctx->op_data;
@@ -183,9 +212,8 @@ _gpgme_release_result (gpgme_ctx_t ctx)
while (data)
{
struct ctx_op_data *next_data = data->next;
- if (data->cleanup)
- (*data->cleanup) (data->hook);
- free (data);
+ data->next = NULL;
+ gpgme_result_unref (data->hook);
data = next_data;
}
ctx->op_data = NULL;
@@ -430,7 +458,7 @@ gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
/* This function provides access to the internal read function; it is
- normally not used. */
+ normally not used. */
ssize_t
gpgme_io_read (int fd, void *buffer, size_t count)
{