Differences From Artifact [9b5e456642]:
- File
src/runtime/hashtable.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 5073) [annotate] [blame] [check-ins using] [more...]
To Artifact [57f764fde9]:
- File src/runtime/hashtable.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 5074) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
73 74 75 76 77 78 79 | return table; } static void resize(struct objc_hashtable *table, uint32_t count) { | | | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | return table; } static void resize(struct objc_hashtable *table, uint32_t count) { uint32_t fullness, nsize; struct objc_hashtable_bucket **ndata; if (count > UINT32_MAX / sizeof(*table->data) || count > UINT32_MAX / 8) OBJC_ERROR("Integer overflow!"); fullness = count * 8 / table->size; |
︙ | ︙ | |||
97 98 99 100 101 102 103 | if (count < table->count && nsize < 16) return; if ((ndata = calloc(nsize, sizeof(sizeof(*ndata)))) == NULL) OBJC_ERROR("Not enough memory to resize hash table!"); | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | if (count < table->count && nsize < 16) return; if ((ndata = calloc(nsize, sizeof(sizeof(*ndata)))) == NULL) OBJC_ERROR("Not enough memory to resize hash table!"); for (uint32_t i = 0; i < table->size; i++) { if (table->data[i] != NULL && table->data[i] != &objc_deleted_bucket) { uint32_t j, last; last = nsize; for (j = table->data[i]->hash & (nsize - 1); |
︙ | ︙ | |||
228 229 230 231 232 233 234 | table->count--; resize(table, table->count); } void objc_hashtable_free(struct objc_hashtable *table) { | < < | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | table->count--; resize(table, table->count); } void objc_hashtable_free(struct objc_hashtable *table) { for (uint32_t i = 0; i < table->size; i++) if (table->data[i] != NULL && table->data[i] != &objc_deleted_bucket) free(table->data[i]); free(table->data); free(table); } |