summaryrefslogtreecommitdiff
path: root/src/secmem.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-12-07 10:37:50 +0100
committerWerner Koch <wk@gnupg.org>2016-12-07 10:37:50 +0100
commitb7df907dca4d525f8930c533b763ffce44ceed87 (patch)
tree0b2306a0487add7c4785112919b490b414482c1b /src/secmem.c
parente366c19b34922c770af82cd035fd815680b29dee (diff)
downloadlibgcrypt-b7df907dca4d525f8930c533b763ffce44ceed87.tar.gz
Give the secmem allocators a hint when a xmalloc calls them.
* src/secmem.c (_gcry_secmem_malloc): New not yet used arg XHINT. (_gcry_secmem_realloc): Ditto. * src/stdmem.c (_gcry_private_malloc_secure): New arg XHINT to be passed to the secmem functions. (_gcry_private_realloc): Ditto. * src/g10lib.h (GCRY_ALLOC_FLAG_XHINT): New. * src/global.c (do_malloc): Pass this flag as XHINT to the private allocator. (_gcry_malloc_secure): Factor code out to ... (_gcry_malloc_secure_core): this. Add arg XHINT. (_gcry_realloc): Factor code out to ... (_gcry_realloc_core): here. Add arg XHINT. (_gcry_strdup): Factor code out to ... (_gcry_strdup_core): here. Add arg XHINT. (_gcry_xrealloc): Use the core function and pass true for XHINT. (_gcry_xmalloc_secure): Ditto. (_gcry_xstrdup): Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'src/secmem.c')
-rw-r--r--src/secmem.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/secmem.c b/src/secmem.c
index 54bbda11..928e03fc 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -608,8 +608,11 @@ _gcry_secmem_malloc_internal (size_t size)
return mb ? &mb->aligned.c : NULL;
}
+
+/* Allocate a block from the secmem of SIZE. With XHINT set assume
+ * that the caller is a xmalloc style function. */
void *
-_gcry_secmem_malloc (size_t size)
+_gcry_secmem_malloc (size_t size, int xhint)
{
void *p;
@@ -694,9 +697,10 @@ _gcry_secmem_realloc_internal (void *p, size_t newsize)
}
-/* Realloc memory. */
+/* Realloc memory. With XHINT set assume that the caller is a xmalloc
+ * style function. */
void *
-_gcry_secmem_realloc (void *p, size_t newsize)
+_gcry_secmem_realloc (void *p, size_t newsize, int xhint)
{
void *a;