Differences From Artifact [38fe5a0cfe]:
- File src/runtime/hashtable.m — part of check-in [cca678886f] at 2017-05-06 19:43:55 on branch trunk — Clean up a few includes (user: js, size: 5100) [annotate] [blame] [check-ins using]
To Artifact [8166d9c683]:
- File
src/runtime/hashtable.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 5107) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
49 50 51 52 53 54 55 | bool objc_equal_string(const void *obj1, const void *obj2) { return (strcmp(obj1, obj2) == 0); } | | | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | bool objc_equal_string(const void *obj1, const void *obj2) { return (strcmp(obj1, obj2) == 0); } struct objc_hashtable * objc_hashtable_new(uint32_t (*hash)(const void *), bool (*equal)(const void *, const void *), uint32_t size) { struct objc_hashtable *table; if ((table = malloc(sizeof(struct objc_hashtable))) == NULL) OBJC_ERROR("Not enough memory to allocate hash table!"); table->hash = hash; table->equal = equal; table->count = 0; table->size = size; table->data = calloc(size, sizeof(struct objc_hashtable_bucket *)); if (table->data == NULL) OBJC_ERROR("Not enough memory to allocate hash table!"); return table; } |
︙ | ︙ | |||
200 201 202 203 204 205 206 | bucket->hash = hash; bucket->obj = obj; table->data[i] = bucket; table->count++; } | | | | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | bucket->hash = hash; bucket->obj = obj; table->data[i] = bucket; table->count++; } void * objc_hashtable_get(struct objc_hashtable *table, const void *key) { uint32_t idx; if (!index_for_key(table, key, &idx)) return NULL; return (void *)table->data[idx]->obj; } void objc_hashtable_delete(struct objc_hashtable *table, const void *key) { uint32_t idx; |
︙ | ︙ |