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/op-support.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/op-support.c')
| -rw-r--r-- | src/op-support.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/op-support.c b/src/op-support.c index 2bcb3a35..885048f2 100644 --- a/src/op-support.c +++ b/src/op-support.c @@ -32,6 +32,7 @@ #include "ops.h" #include "util.h" #include "debug.h" +#include "mem.h" gpgme_error_t @@ -54,7 +55,7 @@ _gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, void **hook, return 0; } - data = calloc (1, sizeof (struct ctx_op_data) + size); + data = _gpgme_calloc (1, sizeof (struct ctx_op_data) + size); if (!data) return gpg_error_from_syserror (); data->magic = CTX_OP_DATA_MAGIC; @@ -199,7 +200,7 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key) char *tail; long int reason; - inv_key = malloc (sizeof (*inv_key)); + inv_key = _gpgme_malloc (sizeof (*inv_key)); if (!inv_key) return gpg_error_from_syserror (); inv_key->next = NULL; @@ -208,7 +209,7 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key) if (errno || args == tail || (*tail && *tail != ' ')) { /* The crypto backend does not behave. */ - free (inv_key); + _gpgme_free (inv_key); return trace_gpg_error (GPG_ERR_INV_ENGINE); } @@ -280,10 +281,10 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key) tail++; if (*tail) { - inv_key->fpr = strdup (tail); + inv_key->fpr = _gpgme_strdup (tail); if (!inv_key->fpr) { - free (inv_key); + _gpgme_free (inv_key); return gpg_error_from_syserror (); } } @@ -329,7 +330,7 @@ _gpgme_parse_plaintext (char *args, char **filenamep) *tail = '\0'; if (filenamep && *args != '\0') { - char *filename = strdup (args); + char *filename = _gpgme_strdup (args); if (!filename) return gpg_error_from_syserror (); |
