| 353 | } |
| 354 | |
| 355 | static void bucket_push(lsh_bucket_t *bucket, int entry_index) { |
| 356 | if (bucket->count >= bucket->cap) { |
| 357 | int new_cap = bucket->cap < BUCKET_INIT_CAP ? BUCKET_INIT_CAP : bucket->cap * GROW_FACTOR; |
| 358 | int *new_items = realloc(bucket->items, (size_t)new_cap * sizeof(int)); |
| 359 | if (!new_items) { |
| 360 | return; |
| 361 | } |
| 362 | bucket->items = new_items; |
| 363 | bucket->cap = new_cap; |
| 364 | } |
| 365 | bucket->items[bucket->count++] = entry_index; |
| 366 | } |
| 367 | |
| 368 | cbm_lsh_index_t *cbm_lsh_new(void) { |
| 369 | cbm_lsh_index_t *idx = calloc(SKIP_ONE, sizeof(cbm_lsh_index_t)); |