Lines Matching refs:table
27 stringtable_init (struct stringtable *table) in stringtable_init() argument
29 table->count = 0; in stringtable_init()
35 table->allocated = 128; in stringtable_init()
37 table->entries = xcalloc (table->allocated, sizeof (table->entries[0])); in stringtable_init()
56 stringtable_rehash (struct stringtable *table) in stringtable_rehash() argument
60 uint32_t new_allocated = table->allocated * 2; in stringtable_rehash()
62 = xcalloc (new_allocated, sizeof (table->entries[0])); in stringtable_rehash()
65 for (uint32_t i = 0; i < table->allocated; ++i) in stringtable_rehash()
66 for (struct stringtable_entry *e = table->entries[i]; e != NULL; ) in stringtable_rehash()
76 free (table->entries); in stringtable_rehash()
77 table->entries = new_entries; in stringtable_rehash()
78 table->allocated = new_allocated; in stringtable_rehash()
82 stringtable_add (struct stringtable *table, const char *string) in stringtable_add() argument
85 if (table->allocated == 0) in stringtable_add()
86 stringtable_init (table); in stringtable_add()
95 = table->entries[hash & (table->allocated - 1)]; in stringtable_add()
102 if (table->count >= (1U << 30)) in stringtable_add()
104 if (table->count * 3 > table->allocated * 2) in stringtable_add()
105 stringtable_rehash (table); in stringtable_add()
108 ++table->count; in stringtable_add()
111 uint32_t index = hash & (table->allocated - 1); in stringtable_add()
112 e->next = table->entries[index]; in stringtable_add()
113 table->entries[index] = e; in stringtable_add()
149 stringtable_finalize (struct stringtable *table, in stringtable_finalize() argument
152 if (table->count == 0) in stringtable_finalize()
160 struct stringtable_entry **array = xcalloc (table->count, sizeof (*array)); in stringtable_finalize()
163 for (uint32_t i = 0; i < table->allocated; ++i) in stringtable_finalize()
164 for (struct stringtable_entry *e = table->entries[i]; e != NULL; in stringtable_finalize()
170 assert (j == table->count); in stringtable_finalize()
172 qsort (array, table->count, sizeof (*array), finalize_compare); in stringtable_finalize()
176 for (uint32_t j = 1; j < table->count; ++j) in stringtable_finalize()
193 struct stringtable_entry *last = array[table->count - 1]; in stringtable_finalize()
204 for (uint32_t i = 0; i < table->allocated; ++i) in stringtable_finalize()
205 for (struct stringtable_entry *e = table->entries[i]; e != NULL; in stringtable_finalize()