Example #1
0
int main()
{
    char line[1024], *key;
    ht = HT_create(1024, 5);

    for (;;)
    {
        if (!fgets(line, 1024, stdin)) break;
        if (line[0] == '?')
        {
            key = malloc(1024);
            memset(key, 0, 1024);
            strcpy(key, line + 1);
            if (HT_get(ht, key)) {
                printf("found\n");
            } else {
                printf("not found\n");
            }
        }
        else
        {
            key = malloc(1024);
            memset(key, 0, 1024);
            strcpy(key, line);
            if (HT_set(ht, key, key, NULL, NULL)) {
                printf("replaced\n");
            } else {
                printf("added\n");
            }
        }
        
    }
    return 0;
}
Example #2
0
unsigned
flow_init (void)
{
  /* in case of reinitialization */
  if (ipv4_hash_table != NULL || ipv6_hash_table != NULL)
    flow_cleanup ();

  /* ipv4 hash table creation */
  ipv4_hash_table =
    HT_create (HT_SIZE, IPV4_HT_KEY_SIZE, sizeof (struct flow_desc));
  if (ipv4_hash_table == NULL)	/* error while creating hash table */
    return 1;			/* failure */

  /* ipv6 hash table creation */
  ipv6_hash_table =
    HT_create (HT_SIZE, IPV6_HT_KEY_SIZE, sizeof (struct flow_desc));
  if (ipv6_hash_table == NULL)	/* error while creating hash table */
    return 1;			/* failure */

  return 0;			/* success */
}
ptr_graph createGraph(int id,int m,int c)
{
	ptr_graph graph;
	ht_ptr table;

	graph = malloc(sizeof(struct graph));
	table = HT_create(m,c);              //duo int gia orismata
	graph->table = table;
	graph->id = id;
	graph->size = 0;

	return graph;

}
Example #4
0
unsigned ipv4_reassembly_init(void)
{
    assert(sizeof (struct hole_desc) == 8);

    /* in case of reinitialization */
    if (hash_table != NULL)
        ipv4_reassembly_cleanup();

    /* reassembly hash table creation */
    hash_table = HT_create(HT_SIZE, HT_KEY_SIZE, sizeof(struct reassembly_desc));
    if (hash_table == NULL) /* error while creating hash table */
	return 1; /* failure */

    return 0; /* success */
}