summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-09-03 18:50:35 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-09-05 14:33:01 -0400
commitbd74dc610a2069f8549a26668940ef655f51598d (patch)
treec22aae3216f8c6ac50466ab8ce83fd58b7f9d77c /lib/command.c
parentf24fdd9921b98f99d63b1299029d177954090243 (diff)
lib: Hash creation cleanup
1) Some hash key functions where converting pointers directly to a 32 bit value via downcasting. Pointers are 64 bit on a majority of our platforms. 2) Some hashes were being created with 256 entries, downsize the hash creation size to more appropriate values. 3) Add hash names to hash creation so we can watch the hash via 'show debugging hashtable' Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/command.c b/lib/command.c
index a303781370..d1b0867372 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -43,6 +43,7 @@
#include "qobj.h"
#include "defaults.h"
#include "libfrr.h"
+#include "jhash.h"
DEFINE_MTYPE(LIB, HOST, "Host config")
DEFINE_MTYPE(LIB, STRVEC, "String vector")
@@ -278,7 +279,9 @@ int argv_find(struct cmd_token **argv, int argc, const char *text, int *index)
static unsigned int cmd_hash_key(void *p)
{
- return (uintptr_t)p;
+ int size = sizeof(p);
+
+ return jhash(p, size, 0);
}
static int cmd_hash_cmp(const void *a, const void *b)
@@ -298,7 +301,9 @@ void install_node(struct cmd_node *node, int (*func)(struct vty *))
cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL);
graph_new_node(node->cmdgraph, token,
(void (*)(void *)) & cmd_token_del);
- node->cmd_hash = hash_create(cmd_hash_key, cmd_hash_cmp, NULL);
+ node->cmd_hash = hash_create_size(16, cmd_hash_key,
+ cmd_hash_cmp,
+ "Command Hash");
}
/**