From 8f5344eed94e56feea8322a9c1805ba38175614d Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 8 Aug 2015 19:17:29 +0200 Subject: [PATCH] config: Add a hash table into the data structure. Signed-off-by: Richard Cochran --- config.c | 11 +++++++++++ config.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/config.c b/config.c index 934caa2..9ef8be1 100644 --- a/config.c +++ b/config.c @@ -24,6 +24,7 @@ #include #include "config.h" #include "ether.h" +#include "hash.h" #include "print.h" #include "util.h" @@ -803,6 +804,15 @@ void config_init_interface(struct interface *iface, struct config *cfg) iface->boundary_clock_jbod = cfg->dds.boundary_clock_jbod; } +int config_init(struct config *cfg) +{ + cfg->htab = hash_create(); + if (!cfg->htab) { + return -1; + } + return 0; +} + void config_destroy(struct config *cfg) { struct interface *iface; @@ -811,4 +821,5 @@ void config_destroy(struct config *cfg) STAILQ_REMOVE_HEAD(&cfg->interfaces, list); free(iface); } + hash_destroy(cfg->htab, free); } diff --git a/config.h b/config.h index 7bff11f..222883a 100644 --- a/config.h +++ b/config.h @@ -60,6 +60,10 @@ struct config { /* configured interfaces */ STAILQ_HEAD(interfaces_head, interface) interfaces; + /* hash of all non-legacy items */ + struct hash *htab; + + /* the rest are legacy fields */ enum timestamp_type timestamping; enum transport_type transport; enum delay_mechanism dm;