All pastes #2059804 Raw Edit

Stuff

public c v1 · immutable
#2059804 ·published 2011-05-15 07:29 UTC
rendered paste body
void htable_add_id(htable_t* hash,value_t* new){  int hash_id = 0;  if ( new == NULL )    printf("ERROR, new == NULL\n");      /* Rehash when load factor is 50%*/   float load = (float) ((float) hash->items / (float) hash->buckets);  if ( load > MAX_LOAD_FACTOR ) {    htable_rehash_id(hash);  }    hash_id = hash_uint( new->id, hash->buckets );  while (hash->array[hash_id] != NULL) {    /* Linear probing */    	 hash_id = ++hash_id % hash->buckets;  }    if ( hash->array[hash_id] == NULL ) {    hash->array[hash_id] = new;  } else {    fprintf(stderr, "There is a problem!\n");  }}