[git] GCRYPT - branch, master, updated. libgcrypt-1.8.1-134-g876f728
by Werner Koch
cvs at cvs.gnupg.org
Wed Dec 12 08:58:05 CET 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".
The branch, master has been updated
via 876f7280e8604bc99ddda0526339ec5ec6b23c4b (commit)
from 66d2b7fc17258f1424f4ca4adb1096e48b818bd0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 876f7280e8604bc99ddda0526339ec5ec6b23c4b
Author: Werner Koch <wk at gnupg.org>
Date: Wed Dec 12 08:34:10 2018 +0100
secmem: Prepare for easier debugging.
* src/secmem.c (_gcry_secmem_dump_stats): Factor code out to ...
(secmem_dump_stats_internal): new.
--
This allows to insert call to the dump function during debug sessions
inside of the allocators or call secmem_dump_stats_internal from gdb.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/src/secmem.c b/src/secmem.c
index b6f07c5..b36c44f 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -118,6 +118,13 @@ GPGRT_LOCK_DEFINE (secmem_lock);
#define ADDR_TO_BLOCK(addr) \
(memblock_t *) (void *) ((char *) addr - BLOCK_HEAD_SIZE)
+/* Prototypes. */
+static void secmem_dump_stats_internal (int extended);
+
+
+/*
+ * Functions
+ */
/* Memory barrier */
static inline void
@@ -657,11 +664,18 @@ _gcry_secmem_malloc_internal (size_t size, int xhint)
return &mb->aligned.c;
}
- /* If we are called from xmalloc style function resort to the
+ /* If we are called from xmalloc style functions resort to the
* overflow pools to return memory. We don't do this in FIPS mode,
- * though. */
+ * though. If the auto-expand option is active we do the expanding
+ * also for the standard malloc functions.
+ *
+ * The idea of using them by default only for the xmalloc function
+ * is so that a user can control whether memory will be allocated in
+ * the initial created mlock protected secmem area or may also be
+ * allocated from the overflow pools. */
if ((xhint || auto_expand) && !fips_mode ())
{
+ /* Check whether we can allocate from the overflow pools. */
for (pool = pool->next; pool; pool = pool->next)
{
mb = mb_get_new (pool, (memblock_t *) pool->mem, size);
@@ -900,12 +914,19 @@ _gcry_secmem_term ()
void
_gcry_secmem_dump_stats (int extended)
{
+ SECMEM_LOCK;
+ secmem_dump_stats_internal (extended);
+ SECMEM_UNLOCK;
+}
+
+
+static void
+secmem_dump_stats_internal (int extended)
+{
pooldesc_t *pool;
memblock_t *mb;
int i, poolno;
- SECMEM_LOCK;
-
for (pool = &mainpool, poolno = 0; pool; pool = pool->next, poolno++)
{
if (!extended)
@@ -928,5 +949,4 @@ _gcry_secmem_dump_stats (int extended)
mb->size);
}
}
- SECMEM_UNLOCK;
}
-----------------------------------------------------------------------
Summary of changes:
src/secmem.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
hooks/post-receive
--
The GNU crypto library
http://git.gnupg.org
_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits
More information about the Gcrypt-devel
mailing list