[svn] gpgme - r1375 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Mon Jun 15 19:05:48 CEST 2009
Author: marcus
Date: 2009-06-15 19:05:47 +0200 (Mon, 15 Jun 2009)
New Revision: 1375
Modified:
trunk/src/ChangeLog
trunk/src/context.h
trunk/src/gpgme.c
trunk/src/gpgme.def
trunk/src/gpgme.h.in
trunk/src/libgpgme.vers
trunk/src/op-support.c
Log:
2009-06-15 Marcus Brinkmann <marcus at g10code.de>
* 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.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/ChangeLog 2009-06-15 17:05:47 UTC (rev 1375)
@@ -1,3 +1,14 @@
+2009-06-15 Marcus Brinkmann <marcus at g10code.de>
+
+ * 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.
+
2009-06-12 Werner Koch <wk at g10code.com>
* gpgme-w32spawn.c (translate_get_from_file): Parse optional spawn
Modified: trunk/src/context.h
===================================================================
--- trunk/src/context.h 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/context.h 2009-06-15 17:05:47 UTC (rev 1375)
@@ -45,7 +45,7 @@
struct ctx_op_data
{
/* The next element in the linked list, or NULL if this is the last
- element. */
+ element. Used by op data structures linked into a context. */
struct ctx_op_data *next;
/* The type of the hook data, which can be used by a routine to
@@ -58,6 +58,9 @@
/* The hook that points to the operation data. */
void *hook;
+
+ /* The number of outstanding references. */
+ int references;
};
typedef struct ctx_op_data *ctx_op_data_t;
Modified: trunk/src/gpgme.c
===================================================================
--- trunk/src/gpgme.c 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/gpgme.c 2009-06-15 17:05:47 UTC (rev 1375)
@@ -176,6 +176,35 @@
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 @@
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 @@
/* 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)
{
Modified: trunk/src/gpgme.def
===================================================================
--- trunk/src/gpgme.def 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/gpgme.def 2009-06-15 17:05:47 UTC (rev 1375)
@@ -177,6 +177,8 @@
gpgme_io_read @136
gpgme_io_write @137
+ gpgme_release_ref @138
+ gpgme_release_unref @139
; END
Modified: trunk/src/gpgme.h.in
===================================================================
--- trunk/src/gpgme.h.in 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/gpgme.h.in 2009-06-15 17:05:47 UTC (rev 1375)
@@ -1934,6 +1934,10 @@
gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
+void gpgme_result_ref (void *result);
+void gpgme_result_unref (void *result);
+
+
/* Deprecated types. */
typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED;
typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED;
Modified: trunk/src/libgpgme.vers
===================================================================
--- trunk/src/libgpgme.vers 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/libgpgme.vers 2009-06-15 17:05:47 UTC (rev 1375)
@@ -56,7 +56,9 @@
gpgme_io_read;
gpgme_io_write;
-
+
+ gpgme_result_ref;
+ gpgme_result_unref;
};
Modified: trunk/src/op-support.c
===================================================================
--- trunk/src/op-support.c 2009-06-12 16:58:45 UTC (rev 1374)
+++ trunk/src/op-support.c 2009-06-15 17:05:47 UTC (rev 1375)
@@ -52,6 +52,7 @@
data->type = type;
data->cleanup = cleanup;
data->hook = (void *) (((char *) data) + sizeof (struct ctx_op_data));
+ data->references = 1;
ctx->op_data = data;
}
*hook = data->hook;
More information about the Gnupg-commits
mailing list