diff options
| author | Ben Kibbey <[email protected]> | 2014-10-10 13:02:09 +0000 |
|---|---|---|
| committer | Ben Kibbey <[email protected]> | 2014-10-16 01:34:10 +0000 |
| commit | aea2c168fc9c12148181dbcc33d7085aad8e6d90 (patch) | |
| tree | 0da3de376e89130822b76edef6d935b294a83d87 /src/keylist.c | |
| parent | build: Implement SYSROOT feature. (diff) | |
| download | gpgme-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/keylist.c')
| -rw-r--r-- | src/keylist.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/keylist.c b/src/keylist.c index 36ee3eaa..ac363365 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -41,6 +41,7 @@ #include "context.h" #include "ops.h" #include "debug.h" +#include "mem.h" struct key_queue_item_s @@ -385,7 +386,7 @@ parse_sec_field15 (gpgme_key_t key, gpgme_subkey_t subkey, char *field) /* Fields starts with a hex digit; thus it is a serial number. */ key->secret = 1; subkey->is_cardkey = 1; - subkey->card_number = strdup (field); + subkey->card_number = _gpgme_strdup (field); if (!subkey->card_number) return gpg_error_from_syserror (); } @@ -564,7 +565,7 @@ keylist_colon_handler (void *priv, char *line) /* Field 8 has the X.509 serial number. */ if (fields >= 8 && (rectype == RT_CRT || rectype == RT_CRS)) { - key->issuer_serial = strdup (field[7]); + key->issuer_serial = _gpgme_strdup (field[7]); if (!key->issuer_serial) return gpg_error_from_syserror (); } @@ -598,7 +599,7 @@ keylist_colon_handler (void *priv, char *line) /* Field 17 has the curve name for ECC. */ if (fields >= 17 && *field[16]) { - subkey->curve = strdup (field[16]); + subkey->curve = _gpgme_strdup (field[16]); if (!subkey->curve) return gpg_error_from_syserror (); } @@ -671,7 +672,7 @@ keylist_colon_handler (void *priv, char *line) /* Field 17 has the curve name for ECC. */ if (fields >= 17 && *field[16]) { - subkey->curve = strdup (field[16]); + subkey->curve = _gpgme_strdup (field[16]); if (!subkey->curve) return gpg_error_from_syserror (); } @@ -702,7 +703,7 @@ keylist_colon_handler (void *priv, char *line) subkey = key->_last_subkey; if (!subkey->fpr) { - subkey->fpr = strdup (field[9]); + subkey->fpr = _gpgme_strdup (field[9]); if (!subkey->fpr) return gpg_error_from_syserror (); } @@ -711,7 +712,7 @@ keylist_colon_handler (void *priv, char *line) /* Field 13 has the gpgsm chain ID (take only the first one). */ if (fields >= 13 && !key->chain_id && *field[12]) { - key->chain_id = strdup (field[12]); + key->chain_id = _gpgme_strdup (field[12]); if (!key->chain_id) return gpg_error_from_syserror (); } @@ -858,7 +859,7 @@ _gpgme_op_keylist_event_cb (void *data, gpgme_event_io_t type, void *type_data) if (err) return; - q = malloc (sizeof *q); + q = _gpgme_malloc (sizeof *q); if (!q) { gpgme_key_unref (key); @@ -1000,7 +1001,7 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key) opd->key_cond = 0; *r_key = queue_item->key; - free (queue_item); + _gpgme_free (queue_item); return TRACE_SUC2 ("key=%p (%s)", *r_key, ((*r_key)->subkeys && (*r_key)->subkeys->fpr) ? |
