/** @brief Frees a TCP session **/ inline static void __tcp_free_session ( pntoh_tcp_session_t session ) { pntoh_tcp_session_t ptr = 0; pntoh_tcp_stream_t item = 0; ntoh_tcp_key_t first = 0; if ( params.sessions_list == session ) params.sessions_list = session->next; else{ for ( ptr = params.sessions_list ; ptr != 0 && ptr->next != session ; ptr = ptr->next ); if ( ptr != 0 ) ptr->next = session->next; } lock_access( &session->lock ); while ( ( first = htable_first ( session->timewait ) ) != 0 ) { item = (pntoh_tcp_stream_t)htable_remove(session->timewait,first,0); lock_access ( &item->lock ); __tcp_free_stream ( session , &item , NTOH_REASON_SYNC , NTOH_REASON_EXIT ); } while ( ( first = htable_first ( session->streams ) ) != 0 ) { item = (pntoh_tcp_stream_t)htable_remove(session->streams,first, 0); lock_access ( &item->lock ); __tcp_free_stream ( session , &item , NTOH_REASON_SYNC , NTOH_REASON_EXIT ); } unlock_access( &session->lock ); pthread_cancel ( session->tID ); pthread_join ( session->tID , 0 ); sem_destroy ( &session->max_streams ); sem_destroy ( &session->max_timewait ); free_lockaccess ( &session->lock ); htable_destroy ( &session->streams ); htable_destroy ( &session->timewait ); free ( session ); return; }
void test_htable_rehash() { htable *ht = htable_create(); assert(htable_capacity(ht) == MIN_HASH_SIZE && "Size is MIN_HASH_SIZE after creation."); htable_insert(ht, "one", "1st value"); htable_insert(ht, "two", "2nd value"); htable_insert(ht, "three", "3rd value"); htable_insert(ht, "four", "4th value"); htable_insert(ht, "five", "5th value"); htable_insert(ht, "six", "6th value"); htable_insert(ht, "seven", "7th value"); htable_insert(ht, "eight", "8th value"); htable_insert(ht, "nine", "9th value"); htable_insert(ht, "ten", "10th value"); htable_insert(ht, "eleven", "11th value"); htable_insert(ht, "twelve", "12th value"); assert(htable_capacity(ht) == 29 && "Size is 29 after rehash."); assert(0 == strcmp("1st value", htable_get(ht, "one")) && "First value should be equal to 1st value"); assert(0 == strcmp("2nd value", htable_get(ht, "two")) && "Second value should be equal to 2nd value"); assert(0 == strcmp("7th value", htable_get(ht, "seven")) && "Third value should be equal to 3rd value"); htable_destroy(ht); }
int test_create__destroy(){ hashtable* myhtable; hsize size=101; myhtable=htable_create(size,NULL); htable_destroy(myhtable); myhtable=NULL; return 1; }
static void map_free_object(zend_object *object) { Map *intern = (Map*) object; zend_object_std_dtor(&intern->std); htable_destroy(intern->table); }
void sip_calls_clear() { // Create again the callid hash table htable_destroy(calls.callids); calls.callids = htable_create(calls.limit); // Remove all items from vector vector_clear(calls.list); vector_clear(calls.active); }
int test_add_element_and_find_it(){ hashtable* myhtable; hsize size=101; myhtable=htable_create(size,NULL); htable_insert(myhtable,"Hugo","Yvaon"); assert(!strcmp("Yvaon",htable_get(myhtable,"Hugo"))); htable_destroy(myhtable); myhtable=NULL; return 1; }
void kfs_destroy(struct inode *inode) { // Should we check ref counts? /* TODO: yes, we should. but not right now. */ //_KDBG("%p %d\n",inode,atomic_read(&inode->i_count)); if ( atomic_read(&inode->i_count ) == 0 ) { if ( inode->files ) htable_destroy( inode->files ); kmem_free( inode ); } }
void test_htable_erase() { htable *ht = htable_create(); htable_insert(ht, "one", "1st value"); htable_insert(ht, "two", "2nd value"); htable_erase(ht, "one"); assert(0 == htable_count(ht, "one") && "Bucket with key one should not exist."); htable_destroy(ht); }
void test_htable_get() { htable *ht = htable_create(); htable_insert(ht, "two", "2nd value"); assert(NULL == htable_get(ht, "one") && "First value should be NULL"); assert(NULL != htable_get(ht, "two") && "Second value should not equal NULL"); assert(0 == strcmp("2nd value", htable_get(ht, "two")) && "Second value should be equal to 2nd value"); htable_destroy(ht); }
void test_htable_probing() { htable *ht = htable_create(); size_t capacity = htable_capacity(ht); assert(_hash_func("one", capacity) == _hash_func("seven", capacity) && "Make sure that the keys gives the same key"); htable_insert(ht, "one", "1st value"); htable_insert(ht, "seven", "7th value"); assert(0 == strcmp("1st value", htable_get(ht, "one")) && "First value should be equal to 1st value"); assert(0 == strcmp("7th value", htable_get(ht, "seven")) && "Seventh value should be equal to 7th value"); htable_destroy(ht); }
suggestion_t * storage_suggest (storage_t *storage, const char *text) { int i; suggestion_t *result; htable_t *hits = htable_create (10, (unsigned (*)(void *)) node_hash, (int (*)(void *, void *)) node_cmp); phrase_t *phrase = phrase_create (text); for (i = 0; i < phrase->word_count; i++){ hit_word (storage->words, hits, phrase->words[i]); } result = extract_and_sort (storage, hits); htable_destroy (hits, destroy_hit); phrase_destroy (phrase); return result; }
void main_phrases (void) { phrase_t *p1 = phrase_create ("ala"); phrase_t *p2 = phrase_create ("ela"); entry_t *entry; htable_t *table = htable_create_p (4); htable_insert (table, p1, p1); htable_insert (table, p2, p2); entry = htable_lookup (table, p2); phrase_print ((phrase_t *) entry->value); printf ("\n"); htable_destroy (table, destroy_entry); }
void sip_calls_clear_soft() { // Create again the callid hash table htable_destroy(calls.callids); calls.callids = htable_create(calls.limit); // Repopulate list applying current filter calls.list = vector_copy_if(sip_calls_vector(), filter_check_call); calls.active = vector_copy_if(sip_active_calls_vector(), filter_check_call); // Repopulate callids based on filtered list sip_call_t *call; vector_iter_t it = vector_iterator(calls.list); while ((call = vector_iterator_next(&it))) { htable_insert(calls.callids, call->callid, call); } }
void test_htable_size() { htable *ht = htable_create(); assert(0 == htable_size(ht) && "Count should be 0 upon creation."); htable_insert(ht, "one", "1st value"); htable_insert(ht, "two", "2nd value"); htable_insert(ht, "three", "3rd value"); assert(3 == htable_size(ht) && "Count should be 3 after three insertions."); htable_clear(ht); assert(0 == htable_size(ht) && "Count should be 0 after clear."); htable_destroy(ht); }
void sip_deinit() { // Remove all calls sip_calls_clear(); // Remove Call-id hash table htable_destroy(calls.callids); // Remove calls vector vector_destroy(calls.list); vector_destroy(calls.active); // Deallocate regular expressions regfree(&calls.reg_method); regfree(&calls.reg_callid); regfree(&calls.reg_xcallid); regfree(&calls.reg_response); regfree(&calls.reg_cseq); regfree(&calls.reg_from); regfree(&calls.reg_to); regfree(&calls.reg_valid); regfree(&calls.reg_cl); regfree(&calls.reg_body); }
static void destroy_storage_internals (storage_t *storage) { if (storage->words) htable_destroy (storage->words, list_destroy); }
void opt_destroy(){ htable_destroy(scan_htable); }
void htable_clear_destroy(t_htable *htable) { htable_clear(htable); htable_destroy(htable); }
void htable_delete(htable* ht) { // {{{ free(htable_destroy(ht)); } // }}}
void capping_destroy(){ htable_destroy(cap_htable); }