Пример #1
0
int um3_transport_init(char *argv[])
{
    udp_addr_t        addr;
    int               asp1_ep, sgp1_ep;

    /* create transport layer endpoints */
    um3_get_asp1_addr(argv, &addr);
    asp1_ep = make_lep(addr);
    um3_get_sgp1_addr(argv, &addr);
    sgp1_ep = make_rep(addr);
    um3_get_cn_addr(argv, &addr);
    sgp1_ep = make_rep(addr);

    /* create associations between the transport layer endpoints */
    make_assoc(asp1_ep, sgp1_ep, 0);
    return 0;
}
Пример #2
0
void dump_group_hash(liberty_hash_table *ht, FILE *outc, FILE *outh)
{
	/* go thru all the hash buckets and print out forward references to the h file */
	liberty_hash_bucket *b;
	liberty_hash_table *t;
	int i;
	
	for(b=ht->all_list;b;b=b->all_next)
	{
		fprintf(outh,"extern liberty_hash_bucket hbuck_%lx;\n", b);
		fprintf(outc,"liberty_hash_bucket hbuck_%lx = { %s, %s, %s, \"%s\", {%s,(void*)0x%lx}  };\n", b,
				make_rep("hbuck",b->next), make_rep("hbuck",b->all_next), make_rep("hbuck",b->all_prev), b->name, make_rep("group",b->item.v1), b->item.v2);
	}
	
    /* print the table */
	fprintf(outc,"liberty_hash_bucket *ht_table_%lx[%d] = {",
			ht->table, ht->size);
	for(i=0;i<ht->size;i++)
	{
		if( ht->table[i] )
			fprintf(outc,"&hbuck_%lx,", ht->table[i]);
		else
			fprintf(outc,"0,");
	}
	fprintf(outc,"};\n");
	
	
	/* print the counts */
	fprintf(outc,"int ht_counts_%lx[%d] = {",
			ht->counts, ht->size);
	for(i=0;i<ht->size;i++)
	{
		fprintf(outc,"%d,", ht->counts[i]);
	}
	fprintf(outc,"};\n");

	/* print the struct */
	fprintf(outc,"liberty_hash_table ht_%lx = {ht_table_%lx, ht_counts_%lx, %s, %s, %d, %d, %d, %d, %d, %d};\n",
			ht,
			ht->table, ht->counts, make_rep("hbuck",ht->all_list), make_rep("hbuck",ht->all_last),
			ht->auto_resize, ht->threshold, ht->size, ht->longest_bucket_string, ht->entry_count, ht->case_insensitive );
}
Пример #3
0
    const char* insert(string_view str, size_t hash) {
        ustring_write_lock_t lock(mutex);
        size_t pos = hash & mask, dist = 0;
        for (;;) {
            if (entries[pos] == 0) break; // found insert pos
            if (entries[pos]->hashed == hash &&
                entries[pos]->length == str.length() &&
                strncmp(entries[pos]->c_str(), str.data(), str.length()) == 0)
                return entries[pos]->c_str(); // same string is already inserted, return the one that is already in the table
            ++dist;
            pos = (pos + dist) & mask; // quadratic probing
        }

        ustring::TableRep* rep = make_rep(str, hash);
        entries[pos] = rep;
        ++num_entries;
        if (2 * num_entries > mask) grow(); // maintain 0.5 load factor
        return rep->c_str();                // rep is now in the table
    }