void pni_iocp_initialize(void *obj) { iocp_t *iocp = (iocp_t *) obj; memset(iocp, 0, sizeof(iocp_t)); pni_shared_pool_create(iocp); iocp->completion_port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); assert(iocp->completion_port != NULL); iocp->iocpdesc_map = pn_hash(PN_OBJECT, 0, 0.75); iocp->zombie_list = pn_list(PN_OBJECT, 0); iocp->iocp_trace = pn_env_bool("PN_TRACE_DRV"); iocp->selector = NULL; }
pni_store_t *pni_store() { pni_store_t *store = (pni_store_t *) malloc(sizeof(pni_store_t)); if (!store) return NULL; store->size = 0; store->streams = NULL; store->store_head = NULL; store->store_tail = NULL; store->window = 0; store->lwm = 0; store->hwm = 0; store->tracked = pn_hash(0, 0.75, PN_REFCOUNT); return store; }
static void test_hash(void) { void *one = pn_class_new(PN_OBJECT, 0); void *two = pn_class_new(PN_OBJECT, 0); void *three = pn_class_new(PN_OBJECT, 0); pn_hash_t *hash = pn_hash(PN_OBJECT, 4, 0.75); pn_hash_put(hash, 0, NULL); pn_hash_put(hash, 1, one); pn_hash_put(hash, 2, two); pn_hash_put(hash, 3, three); pn_hash_put(hash, 4, one); pn_hash_put(hash, 5, two); pn_hash_put(hash, 6, three); pn_hash_put(hash, 7, one); pn_hash_put(hash, 8, two); pn_hash_put(hash, 9, three); pn_hash_put(hash, 10, one); pn_hash_put(hash, 11, two); pn_hash_put(hash, 12, three); pn_hash_put(hash, 18, one); assert(pn_hash_get(hash, 2) == two); assert(pn_hash_get(hash, 5) == two); assert(pn_hash_get(hash, 18) == one); assert(pn_hash_get(hash, 0) == NULL); assert(pn_hash_size(hash) == 14); pn_hash_del(hash, 5); assert(pn_hash_get(hash, 5) == NULL); assert(pn_hash_size(hash) == 13); pn_hash_del(hash, 18); assert(pn_hash_get(hash, 18) == NULL); assert(pn_hash_size(hash) == 12); pn_decref(hash); pn_decref(one); pn_decref(two); pn_decref(three); }