jnx_hashmap* jnx_hash_create(jnx_unsigned_int size) { JNXCHECK(size); jnx_hashmap* hashmap = (jnx_hashmap*)malloc(sizeof(jnx_hashmap)); hashmap->data = (jnx_hash_element*)calloc(size, sizeof(jnx_hash_element)); hashmap->size = size; hashmap->used_up = 0; hashmap->internal_lock = jnx_thread_mutex_create(); return hashmap; }
jnx_btree* jnx_btree_create(jnx_int32 order, compare_keys callback) { if ( order <= 1 ) { return NULL; } jnx_btree *tree = calloc(1, sizeof(jnx_btree)); tree->order = order; tree->compare_function = callback; tree->root = new_node(tree->order, 1); tree->internal_lock = jnx_thread_mutex_create(); return tree; }
discovery_service *discovery_service_create(int port, unsigned int family, char *broadcast_group_address, peerstore *peers) { discovery_service *svc = calloc(1, sizeof(discovery_service)); svc->port = port; svc->family = family; svc->broadcast_group_address = broadcast_group_address; svc->receive_callback = discovery_receive_handler; svc->isrunning = 0; svc->peers = peers; svc->update_thread = NULL; svc->listening_thread = NULL; svc->last_updated = time(0); svc->update_time_lock = jnx_thread_mutex_create(); return svc; }