Reorganize code in secmem.c.
authorWerner Koch <wk@gnupg.org>
Tue, 6 Dec 2016 20:20:54 +0000 (21:20 +0100)
committerWerner Koch <wk@gnupg.org>
Tue, 6 Dec 2016 20:20:54 +0000 (21:20 +0100)
commit603f479a919311f720a05da738150c2192d5e562
tree31e703c288dbb6e3bc8b21da7058f691884e9df4
parenta0580d446fef648a177ca4ab060d0e449780db84
Reorganize code in secmem.c.

* src/secmem.c (pooldesc_t): New type to collect information about one
pool.
(pool_size): Remove.  Now a member of pooldesc_t.
(pool_okay): Ditto.
(pool_is_mmapped): Ditto.
(pool): Rename variable ...
(mainpool): And change type to pooldesc_t.
(ptr_into_pool_p): Add arg 'pool'.
(mb_get_next): Ditto.
(mb_get_prev): Ditto.
(mb_merge): Ditto.
(mb_get_new): Ditto.
(init_pool): Ditto.
(lock_pool): Rename to ...
(look_pool_pages: this.
(secmem_init): Rename to ...
(_gcry_secmem_init_internal): this.  Add local var POOL and init with
address of MAINPOOL.
(_gcry_secmem_malloc_internal): Add local var POOL and init with
address of MAINPOOL.
(_gcry_private_is_secure): Ditto.
(_gcry_secmem_term): Ditto.
(_gcry_secmem_dump_stats): Ditto.
(_gcry_secmem_free_internal): Ditto.  Remove check for NULL arg.
(_gcry_secmem_free): Add check for NULL arg before taking the lock.
(_gcry_secmem_realloc): Factor most code out to ...
(_gcry_secmem_realloc_internal): this.
--

This change prepares future work to allow the use of several pools.

Signed-off-by: Werner Koch <wk@gnupg.org>
src/secmem.c