예제 #1
0
/** @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;
}
예제 #2
0
파일: test_hash.c 프로젝트: alexceder/libds
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);
}
예제 #3
0
int test_create__destroy(){
  hashtable* myhtable;
  hsize size=101;
  myhtable=htable_create(size,NULL);
  htable_destroy(myhtable);
  myhtable=NULL;
  return 1;
}
예제 #4
0
static void map_free_object(zend_object *object)
{
    Map *intern = (Map*) object;

    zend_object_std_dtor(&intern->std);

    htable_destroy(intern->table);
}
예제 #5
0
파일: sip.c 프로젝트: digitainc/sngrep
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);
}
예제 #6
0
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;
}
예제 #7
0
파일: kfs.c 프로젝트: HobbesOSR/kitten
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 );
	}
}
예제 #8
0
파일: test_hash.c 프로젝트: alexceder/libds
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);
}
예제 #9
0
파일: test_hash.c 프로젝트: alexceder/libds
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);
}
예제 #10
0
파일: test_hash.c 프로젝트: alexceder/libds
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);
}
예제 #11
0
파일: storage.c 프로젝트: kitbs/open-tran
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;
}
예제 #12
0
파일: main.c 프로젝트: kitbs/open-tran
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);
}
예제 #13
0
파일: sip.c 프로젝트: irontec/sngrep
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);
        }
}
예제 #14
0
파일: test_hash.c 프로젝트: alexceder/libds
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);
}
예제 #15
0
파일: sip.c 프로젝트: digitainc/sngrep
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);
}
예제 #16
0
파일: storage.c 프로젝트: kitbs/open-tran
static void
destroy_storage_internals (storage_t *storage)
{
        if (storage->words)
                htable_destroy (storage->words, list_destroy);
}
예제 #17
0
파일: defrag.c 프로젝트: jack2007/Deduper
void opt_destroy(){
	htable_destroy(scan_htable);
	
}
예제 #18
0
파일: htable_rm.c 프로젝트: akabab/Lemin
void		htable_clear_destroy(t_htable *htable)
{
	htable_clear(htable);
	htable_destroy(htable);
}
예제 #19
0
파일: htable.c 프로젝트: garana/filededup
void htable_delete(htable* ht) { // {{{
	free(htable_destroy(ht));
} // }}}
예제 #20
0
파일: capping.c 프로젝트: jack2007/Deduper
void capping_destroy(){
	htable_destroy(cap_htable);
	
}