aboutsummaryrefslogtreecommitdiffstats
path: root/src/posix-util.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/posix-util.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/posix-util.c')
-rw-r--r--src/posix-util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/posix-util.c b/src/posix-util.c
index f7e0a171..55a076e9 100644
--- a/src/posix-util.c
+++ b/src/posix-util.c
@@ -30,6 +30,7 @@
#include "util.h"
#include "sys-util.h"
#include "debug.h"
+#include "mem.h"
/* These variables store the malloced name of alternative default
binaries. The are set only once by gpgme_set_global_flag. */
@@ -49,7 +50,7 @@ _gpgme_set_default_gpg_name (const char *name)
name = s + 1;
if (!default_gpg_name)
- default_gpg_name = strdup (name);
+ default_gpg_name = _gpgme_strdup (name);
return !default_gpg_name;
}
@@ -66,7 +67,7 @@ _gpgme_set_default_gpgconf_name (const char *name)
name = s + 1;
if (!default_gpgconf_name)
- default_gpgconf_name = strdup (name);
+ default_gpgconf_name = _gpgme_strdup (name);
return !default_gpgconf_name;
}
@@ -86,7 +87,7 @@ walk_path (const char *pgm)
orig_path = "/bin:/usr/bin";
#endif
- fname = malloc (strlen (orig_path) + 1 + strlen (pgm) + 1);
+ fname = _gpgme_malloc (strlen (orig_path) + 1 + strlen (pgm) + 1);
if (!fname)
return NULL;
@@ -108,7 +109,7 @@ walk_path (const char *pgm)
_gpgme_debug (DEBUG_ENGINE, "gpgme-walk_path: '%s' not found in '%s'",
pgm, orig_path);
- free (fname);
+ _gpgme_free (fname);
return NULL;
}