Example #1
0
File: node.c Project: tonyg/hop
void register_node_class(node_class_t *nc) {
  cmsg_bytes_t key = cmsg_cstring_bytes(nc->name);
  if (hashtable_contains(&node_class_table, key)) {
    die("Duplicate node class name %s\n", nc->name);
  }
  hashtable_put(&node_class_table, key, nc);
}
Example #2
0
bool mapping_contains(const node *mapping, uint8_t *scalar, size_t length)
{
    PRECOND_NONNULL_ELSE_FALSE(mapping, scalar);
    PRECOND_ELSE_FALSE(MAPPING == node_kind(mapping), 0 < length);

    node *key = make_scalar_node(scalar, length, SCALAR_STRING);
    bool result = hashtable_contains(mapping->content.mapping, key);
    node_free(key);

    return result;
}
Example #3
0
File: node.c Project: tonyg/hop
int bind_node(cmsg_bytes_t name, node_t *n) {
  if (name.len == 0) {
    warn("Binding to empty name forbidden\n");
    return 0;
  }
  if (hashtable_contains(&directory, name)) {
    return 0;
  }
  hashtable_put(&directory, name, n);
  hashtable_put(&n->names, name, NULL);
  info("Binding node <<%.*s>> of class %s\n", name.len, name.bytes, n->node_class->name);
  announce_binding(name, 1);
  return 1;
}
Example #4
0
boolean hashtable_add(hashtable_t* hashtable, void* key, void* item)
{
	if (hashtable_contains(hashtable, key))
		return false;

	uint hash = hashtable->hash(key, hashtable->key_size);
	if (_inner_hashtable_add(hashtable->items, hashtable->keys, hashtable->capacity, hash, hashtable->key_size, key, item))
	{
		hashtable->count++;
		return true;
	}

	return false;
}