All pastes #2059132 Raw Edit

Stuff

public text v1 · immutable
#2059132 ·published 2011-05-14 12:48 UTC
rendered paste body
void htable_rehash_term(htable_t* hash)
{
  printf ("--- Rehash Term! ---\n");
  htable_t* new_ht;
  int size, i;
  
  /* Increase the size of the table */
  size = hash->items * 4;
  new_ht = new_htable(size);
  value_t* new_table = (value_t*) safe_malloc( sizeof(value_t*) * size );
  
  for (i=0; i<hash->buckets; i++) {
	  if ( hash->array[i] != NULL ) {
		  htable_add_term(new_ht, hash->array[i]);
	  }
  }
  
  hash->buckets = size;
  free(hash->array);
  
  hash->array = new_ht->array;
  
  /* TODO: Potential leaks here */
  free(new_ht);
  
}