diff options
author | Werner Koch <[email protected]> | 2017-12-22 11:55:32 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-12-22 11:55:46 +0000 |
commit | f3ba66781a07af2e32f5887e6e15acdd4822a431 (patch) | |
tree | 06d8e033bdf2298f0822727ebcc43690fb1d2a2a /kbx/keybox-util.c | |
parent | common: Use larger buffer for homedir in case of 64 bit UIDs. (diff) | |
download | gnupg-f3ba66781a07af2e32f5887e6e15acdd4822a431.tar.gz gnupg-f3ba66781a07af2e32f5887e6e15acdd4822a431.zip |
kbx: Simplify by removing custom memory functions.
* kbx/keybox-util.c (keybox_set_malloc_hooks): Remove.
(_keybox_malloc, _keybox_calloc, keybox_realloc)
(_keybox_free): Remove.
(keybox_file_rename): Remove. Was not used.
* sm/gpgsm.c (main): Remove call to keybox_set_malloc_hooks.
* kbx/kbxutil.c (main): Ditto.
* kbx/keybox-defs.h: Remove all separate includes. Include util.h.
remove convenience macros.
* common/logging.h (return_if_fail): New. Originally from
keybox-defs.h but now using log_debug.
(return_null_if_fail): Ditto.
(return_val_if_fail): Ditto.
(never_reached): Ditto.
--
Originally the KBX code was written to allow standalone use. However
this required lot of ugliness like separate memory allocators and
such. It also precludes the use of some standard functions from
common due to their use of the common gnupg malloc functions.
Dropping all that makes things easier. Minor disadvantages: the kbx
call done for gpg will now use gcry malloc fucntions and not the
standard malloc functions. This might be a bit slower but removing
them even fixes a possible bug in keybox_tmp_names which is used in
gpg and uses gpg's xfree which is actually gcry_free.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'kbx/keybox-util.c')
-rw-r--r-- | kbx/keybox-util.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/kbx/keybox-util.c b/kbx/keybox-util.c index b71335b7d..3ce5162cc 100644 --- a/kbx/keybox-util.c +++ b/kbx/keybox-util.c @@ -27,52 +27,6 @@ #endif #include "keybox-defs.h" -#include "../common/utilproto.h" - - -static void *(*alloc_func)(size_t n) = malloc; -static void *(*realloc_func)(void *p, size_t n) = realloc; -static void (*free_func)(void*) = free; - - - -void -keybox_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), - void *(*new_realloc_func)(void *p, size_t n), - void (*new_free_func)(void*) ) -{ - alloc_func = new_alloc_func; - realloc_func = new_realloc_func; - free_func = new_free_func; -} - -void * -_keybox_malloc (size_t n) -{ - return alloc_func (n); -} - -void * -_keybox_realloc (void *a, size_t n) -{ - return realloc_func (a, n); -} - -void * -_keybox_calloc (size_t n, size_t m) -{ - void *p = _keybox_malloc (n*m); - if (p) - memset (p, 0, n* m); - return p; -} - -void -_keybox_free (void *p) -{ - if (p) - free_func (p); -} /* Store the two malloced temporary file names used for keybox updates @@ -146,10 +100,3 @@ keybox_tmp_names (const char *filename, int for_keyring, *r_tmpname = tmp_name; return 0; } - -gpg_error_t -keybox_file_rename (const char *oldname, const char *newname, - int *block_signals) -{ - return gnupg_rename_file (oldname, newname, block_signals); -} |