dirmngr: Refactor variable-sized array code.
authorJustus Winter <justus@g10code.com>
Tue, 20 Jun 2017 12:54:17 +0000 (14:54 +0200)
committerJustus Winter <justus@g10code.com>
Tue, 20 Jun 2017 14:37:11 +0000 (16:37 +0200)
commitfc4834d213af031b456c49c1ba5b5ef8873d1f18
tree3fbb901b6e3dc8be2a91862b0ae2da1ae0842e17
parent794261c4bdb271060125feda534a26580c6b9f26
dirmngr: Refactor variable-sized array code.

* dirmngr/ks-engine-hkp.c (struct hostinfo_s): Add explicit length and
size fields.
(MAX_POOL_SIZE): New macro.
(create_new_hostinfo): Initialize new fields.
(host_in_pool_p): Adapt.
(select_random_host): Likewise.
(add_host): Likewise.  Move the resizing logic here.
(hostinfo_sort_pool): New function.
(map_host): Simplify.  Move the resizing logic away from here.
(ks_hkp_mark_host): Adapt.
(ks_hkp_print_hosttable): Likewise.
--

The current code assumes that the pool array is only filled when the
hostinfo object is created.  This patch removes that limitation.

GnuPG-bug-id: 3033
Signed-off-by: Justus Winter <justus@g10code.com>
dirmngr/ks-engine-hkp.c