Advertisement
Guest User

Untitled

a guest
May 29th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. void _setTableSize(struct hashMap *ht, int newTableSize)
  2. {
  3.     struct hashLink **oldTable = ht->table;
  4.     int oldSize = ht->tableSize;
  5.     _initMap(ht, 2 * oldSize);
  6.  
  7.     /* iterate through the old table, and place all linked lists into the new table */
  8.     for (int n = 0; n < oldSize; n++) {
  9.         struct hashLink *current = oldTable[n];
  10.  
  11.         while (current) {           // While current is not NULL
  12.             struct hashLink *temp = current->next;
  13.             insertMap(ht, current->key, current->value);
  14.             free(current); // Free the memory being held by the link
  15.             current = temp;
  16.         }
  17.     }
  18.     /* Free the memory being held by the old table */
  19.     free(oldTable);
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement