diff options
author | Vijayabhaskar Katamreddy <vkatamre@cisco.com> | 2017-12-14 13:20:50 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2018-01-24 00:36:05 +0000 |
commit | fb8e61cd93178f56a1fc91d438e8b2eec46f1522 (patch) | |
tree | eeaafda607eb501272a7f7b3c9e1b5cab8b31599 /src/vppinfra/bihash_template.c | |
parent | 3a905e69b8ae1166c0be0c84770889538b43bacf (diff) |
Adding a format function for bihash init routine to format the key, value, when verbose option is used
Change-Id: Ib63ead4525332f897b8a1d8a4cf5a0eb1da1e7f3
Signed-off-by: Vijayabhaskar Katamreddy <vkatamre@cisco.com>
Diffstat (limited to 'src/vppinfra/bihash_template.c')
-rw-r--r-- | src/vppinfra/bihash_template.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index 56c410b5a51..3f25b02d5df 100644 --- a/src/vppinfra/bihash_template.c +++ b/src/vppinfra/bihash_template.c @@ -41,6 +41,14 @@ void BV (clib_bihash_init) BV (clib_bihash_reset_cache) (h->buckets + i); clib_mem_set_heap (oldheap); + + h->fmt_fn = NULL; +} + +void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h, + format_function_t * fmt_fn) +{ + h->fmt_fn = fmt_fn; } void BV (clib_bihash_free) (BVT (clib_bihash) * h) @@ -566,9 +574,18 @@ u8 *BV (format_bihash) (u8 * s, va_list * args) } if (verbose) { - s = format (s, " %d: %U\n", - j * BIHASH_KVP_PER_PAGE + k, - BV (format_bihash_kvp), &(v->kvp[k])); + if (h->fmt_fn) + { + s = format (s, " %d: %U\n", + j * BIHASH_KVP_PER_PAGE + k, + h->fmt_fn, &(v->kvp[k])); + } + else + { + s = format (s, " %d: %U\n", + j * BIHASH_KVP_PER_PAGE + k, + BV (format_bihash_kvp), &(v->kvp[k])); + } } active_elements++; } |