aboutsummaryrefslogtreecommitdiffstats
path: root/src/key.c
diff options
context:
space:
mode:
authorBen Kibbey <[email protected]>2014-10-10 13:02:09 +0000
committerBen Kibbey <[email protected]>2014-10-16 01:34:10 +0000
commitaea2c168fc9c12148181dbcc33d7085aad8e6d90 (patch)
tree0da3de376e89130822b76edef6d935b294a83d87 /src/key.c
parentbuild: Implement SYSROOT feature. (diff)
downloadgpgme-aea2c168fc9c12148181dbcc33d7085aad8e6d90.tar.gz
gpgme-aea2c168fc9c12148181dbcc33d7085aad8e6d90.zip
Add gpgme_set_global_malloc_hooks().
* configure.ac: Remove check for vasprintf(). * doc/gpgme.texi: Add documentation. * src/gpgme.h.in (gpgme_malloc_hooks,gpgme_malloc_hooks_t): New. * src/gpgme.h.in (gpgme_set_global_malloc_hooks): New prototype. * src/mem.c, src/mem.h: New. * src/gpgme.c (gpgme_set_global_malloc_hooks): New. * src/gpgme.def, src/libgpgme.vers: Add gpgme_set_global_malloc_hooks. * src/vasprintf.c (vasprintf): Rename to _gpgme_vasprintf(). * src/vasprintf.c (asprintf): Rename to _gpgme_asprintf(). * src/Makefile.am: Add mem.c, mem.h and vasprintf.c to main_sources. * src/assuan-support.c, src/ath-pthread.c, src/conversion.c, src/data-compat.c, src/data-identify.c, src/data-mem.c, src/data.c, src/debug.c, src/decrypt.c, src/dirinfo.c, src/encrypt.c, src/engine-assuan.c, src/engine-g13.c, src/engine-gpg.c, src/engine-gpgconf.c, src/engine-gpgsm.c, src/engine-spawn.c, src/engine-uiserver.c, src/engine.c, src/export.c, src/genkey.c, src/get-env.c, src/gpgme-w32spawn.c, src/gpgme.c, src/import.c, src/key.c, src/keylist.c, src/op-support.c, src/passphrase.c, src/posix-io.c, src/posix-util.c, src/progress.c, src/setenv.c, src/sig-notation.c, src/sign.c, src/signers.c, src/trust-item.c, src/trustlist.c, src/util.h, src/verify.c, src/version.c, src/vfs-create.c, src/vfs-mount.c, src/w32-ce.c, src/w32-ce.h, src/w32-glib-io.c, src/w32-io.c, src/w32-sema.c, src/w32-util.c, src/wait-global.c, src/wait.c: Change allocation functions: free() to _gpgme_free(), malloc() to _gpgme_malloc(), calloc() to _gpgme_calloc(), realloc() to _gpgme_realloc() and strdup() to _gpgme_strdup(). -- Mostly borrowed from libassuan for custom memory handling. This changes vasprintf.c to implement _gpgme_asprintf() and _gpgme_vasprintf() and will always use the built-in vasprintf() even when provided by the OS.
Diffstat (limited to 'src/key.c')
-rw-r--r--src/key.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/key.c b/src/key.c
index 1a68966d..1ccecd89 100644
--- a/src/key.c
+++ b/src/key.c
@@ -31,6 +31,7 @@
#include "ops.h"
#include "sema.h"
#include "debug.h"
+#include "mem.h"
/* Protects all reference counters in keys. All other accesses to a
@@ -44,7 +45,7 @@ _gpgme_key_new (gpgme_key_t *r_key)
{
gpgme_key_t key;
- key = calloc (1, sizeof *key);
+ key = _gpgme_calloc (1, sizeof *key);
if (!key)
return gpg_error_from_syserror ();
key->_refs = 1;
@@ -59,7 +60,7 @@ _gpgme_key_add_subkey (gpgme_key_t key, gpgme_subkey_t *r_subkey)
{
gpgme_subkey_t subkey;
- subkey = calloc (1, sizeof *subkey);
+ subkey = _gpgme_calloc (1, sizeof *subkey);
if (!subkey)
return gpg_error_from_syserror ();
subkey->keyid = subkey->_keyid;
@@ -213,7 +214,7 @@ _gpgme_key_append_name (gpgme_key_t key, const char *src, int convert)
/* We can malloc a buffer of the same length, because the converted
string will never be larger. Actually we allocate it twice the
size, so that we are able to store the parsed stuff there too. */
- uid = malloc (sizeof (*uid) + 2 * src_len + 3);
+ uid = _gpgme_malloc (sizeof (*uid) + 2 * src_len + 3);
if (!uid)
return gpg_error_from_syserror ();
memset (uid, 0, sizeof *uid);
@@ -258,7 +259,7 @@ _gpgme_key_add_sig (gpgme_key_t key, char *src)
/* We can malloc a buffer of the same length, because the converted
string will never be larger. Actually we allocate it twice the
size, so that we are able to store the parsed stuff there too. */
- sig = malloc (sizeof (*sig) + 2 * src_len + 3);
+ sig = _gpgme_malloc (sizeof (*sig) + 2 * src_len + 3);
if (!sig)
return NULL;
memset (sig, 0, sizeof *sig);
@@ -330,12 +331,12 @@ gpgme_key_unref (gpgme_key_t key)
{
gpgme_subkey_t next = subkey->next;
if (subkey->fpr)
- free (subkey->fpr);
+ _gpgme_free (subkey->fpr);
if (subkey->curve)
- free (subkey->curve);
+ _gpgme_free (subkey->curve);
if (subkey->card_number)
- free (subkey->card_number);
- free (subkey);
+ _gpgme_free (subkey->card_number);
+ _gpgme_free (subkey);
subkey = next;
}
@@ -358,22 +359,22 @@ gpgme_key_unref (gpgme_key_t key)
notation = next_notation;
}
- free (keysig);
+ _gpgme_free (keysig);
keysig = next_keysig;
}
- free (uid);
+ _gpgme_free (uid);
uid = next_uid;
}
if (key->issuer_serial)
- free (key->issuer_serial);
+ _gpgme_free (key->issuer_serial);
if (key->issuer_name)
- free (key->issuer_name);
+ _gpgme_free (key->issuer_name);
if (key->chain_id)
- free (key->chain_id);
+ _gpgme_free (key->chain_id);
- free (key);
+ _gpgme_free (key);
}