From f50bac1bb25b02d7f086627c4c0a0709ee0f61d5 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Fri, 6 Dec 2019 05:53:17 +0000 Subject: vppinfra: bihash walk cb typedef and continue/stop controls Type: feature Change-Id: I28f7a658be3f3beec9ea32635b60d1d3a10d9b06 Signed-off-by: Neale Ranns --- src/vppinfra/bihash_template.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/vppinfra/bihash_template.c') diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index 97c4cd08eb1..b090041ad29 100644 --- a/src/vppinfra/bihash_template.c +++ b/src/vppinfra/bihash_template.c @@ -906,12 +906,12 @@ u8 *BV (format_bihash) (u8 * s, va_list * args) } void BV (clib_bihash_foreach_key_value_pair) - (BVT (clib_bihash) * h, void *callback, void *arg) + (BVT (clib_bihash) * h, + BV (clib_bihash_foreach_key_value_pair_cb) cb, void *arg) { int i, j, k; BVT (clib_bihash_bucket) * b; BVT (clib_bihash_value) * v; - void (*fp) (BVT (clib_bihash_kv) *, void *) = callback; if (PREDICT_FALSE (alloc_arena (h) == 0)) return; @@ -930,7 +930,8 @@ void BV (clib_bihash_foreach_key_value_pair) if (BV (clib_bihash_is_free) (&v->kvp[k])) continue; - (*fp) (&v->kvp[k], arg); + if (BIHASH_WALK_STOP == cb (&v->kvp[k], arg)) + return; /* * In case the callback deletes the last entry in the bucket... */ -- cgit 1.2.3-korg