Skip to content

Commit

Permalink
config: Add a hash table into the data structure.
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Aug 16, 2015
1 parent 8601aa3 commit 8f5344e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string.h>
#include "config.h"
#include "ether.h"
#include "hash.h"
#include "print.h"
#include "util.h"

Expand Down Expand Up @@ -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;
Expand All @@ -811,4 +821,5 @@ void config_destroy(struct config *cfg)
STAILQ_REMOVE_HEAD(&cfg->interfaces, list);
free(iface);
}
hash_destroy(cfg->htab, free);
}
4 changes: 4 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8f5344e

Please sign in to comment.