summaryrefslogtreecommitdiff
path: root/lib/qobj.c
diff options
context:
space:
mode:
authorwhitespace / reindent <invalid@invalid.invalid>2017-08-09 11:49:42 +0200
committerwhitespace / reindent <invalid@invalid.invalid>2017-08-09 12:03:17 +0200
commitac4d0be5874fafd14212d6007fff7495edc9b152 (patch)
tree5e2f0d3189de928c849f9983406389ade3b098cb /lib/qobj.c
parent76a86854181c27819e5cf71b12ae1fa5ccd9e02a (diff)
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/qobj.c')
-rw-r--r--lib/qobj.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/lib/qobj.c b/lib/qobj.c
index 8a386d2486..4a681b4d9b 100644
--- a/lib/qobj.c
+++ b/lib/qobj.c
@@ -29,57 +29,56 @@
static struct hash *nodes = NULL;
-static unsigned int qobj_key (void *data)
+static unsigned int qobj_key(void *data)
{
- struct qobj_node *node = data;
- return (unsigned int)node->nid;
+ struct qobj_node *node = data;
+ return (unsigned int)node->nid;
}
-static int qobj_cmp (const void *a, const void *b)
+static int qobj_cmp(const void *a, const void *b)
{
- const struct qobj_node *na = a, *nb = b;
- return na->nid == nb->nid;
+ const struct qobj_node *na = a, *nb = b;
+ return na->nid == nb->nid;
}
void qobj_reg(struct qobj_node *node, struct qobj_nodetype *type)
{
- node->type = type;
- do
- {
- node->nid = (uint64_t)random();
- node->nid ^= (uint64_t)random() << 32;
- }
- while (!node->nid || hash_get (nodes, node, hash_alloc_intern) != node);
+ node->type = type;
+ do {
+ node->nid = (uint64_t)random();
+ node->nid ^= (uint64_t)random() << 32;
+ } while (!node->nid
+ || hash_get(nodes, node, hash_alloc_intern) != node);
}
void qobj_unreg(struct qobj_node *node)
{
- hash_release (nodes, node);
+ hash_release(nodes, node);
}
struct qobj_node *qobj_get(uint64_t id)
{
- struct qobj_node dummy = { .nid = id };
- return hash_lookup (nodes, &dummy);
+ struct qobj_node dummy = {.nid = id};
+ return hash_lookup(nodes, &dummy);
}
void *qobj_get_typed(uint64_t id, struct qobj_nodetype *type)
{
- struct qobj_node *node = qobj_get(id);
- if (!node || node->type != type)
- return NULL;
- return (char *)node - node->type->node_member_offset;
+ struct qobj_node *node = qobj_get(id);
+ if (!node || node->type != type)
+ return NULL;
+ return (char *)node - node->type->node_member_offset;
}
-void qobj_init (void)
+void qobj_init(void)
{
- if (!nodes)
- nodes = hash_create (qobj_key, qobj_cmp);
+ if (!nodes)
+ nodes = hash_create(qobj_key, qobj_cmp);
}
-void qobj_finish (void)
+void qobj_finish(void)
{
- hash_clean (nodes, NULL);
- hash_free (nodes);
- nodes = NULL;
+ hash_clean(nodes, NULL);
+ hash_free(nodes);
+ nodes = NULL;
}