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/wait.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/wait.c')
-rw-r--r-- | src/wait.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -38,6 +38,7 @@ #include "priv-io.h" #include "engine.h" #include "debug.h" +#include "mem.h" void @@ -51,7 +52,7 @@ void _gpgme_fd_table_deinit (fd_table_t fdt) { if (fdt->fds) - free (fdt->fds); + _gpgme_free (fdt->fds); } @@ -70,7 +71,7 @@ fd_table_put (fd_table_t fdt, int fd, int dir, void *opaque, int *idx) if (i == fdt->size) { #define FDT_ALLOCSIZE 10 - new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE) + new_fds = _gpgme_realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE) * sizeof (*new_fds)); if (!new_fds) return gpg_error_from_syserror (); @@ -111,16 +112,16 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, fdt = &ctx->fdt; assert (fdt); - tag = malloc (sizeof *tag); + tag = _gpgme_malloc (sizeof *tag); if (!tag) return gpg_error_from_syserror (); tag->ctx = ctx; /* Allocate a structure to hold information about the handler. */ - item = calloc (1, sizeof *item); + item = _gpgme_calloc (1, sizeof *item); if (!item) { - free (tag); + _gpgme_free (tag); return gpg_error_from_syserror (); } item->ctx = ctx; @@ -131,8 +132,8 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, err = fd_table_put (fdt, fd, dir, item, &tag->idx); if (err) { - free (tag); - free (item); + _gpgme_free (tag); + _gpgme_free (item); return err; } @@ -163,8 +164,8 @@ _gpgme_remove_io_cb (void *data) "setting fd 0x%x (item=%p) done", fdt->fds[idx].fd, fdt->fds[idx].opaque); - free (fdt->fds[idx].opaque); - free (tag); + _gpgme_free (fdt->fds[idx].opaque); + _gpgme_free (tag); /* Free the table entry. */ fdt->fds[idx].fd = -1; |