Lines Matching refs:capacity
9 static inline ds_htable_bucket_t *ds_htable_allocate_buckets(uint32_t capacity) in ds_htable_allocate_buckets() argument
11 return ecalloc(capacity, sizeof(ds_htable_bucket_t)); in ds_htable_allocate_buckets()
14 …atic inline ds_htable_bucket_t *ds_htable_reallocate_buckets(ds_htable_t *table, uint32_t capacity) in ds_htable_reallocate_buckets() argument
16 return erealloc(table->buckets, capacity * sizeof(ds_htable_bucket_t)); in ds_htable_reallocate_buckets()
19 static inline uint32_t *ds_htable_allocate_lookup(uint32_t capacity) in ds_htable_allocate_lookup() argument
21 return emalloc(capacity * sizeof(uint32_t)); in ds_htable_allocate_lookup()
24 static inline uint32_t *ds_htable_reallocate_lookup(uint32_t *lookup, uint32_t capacity) in ds_htable_reallocate_lookup() argument
26 return erealloc(lookup, capacity * sizeof(uint32_t)); in ds_htable_reallocate_lookup()
31 memset(table->lookup, DS_HTABLE_INVALID_INDEX, table->capacity * sizeof(uint32_t)); in ds_htable_reset_lookup()
34 static inline void ds_htable_realloc(ds_htable_t *table, uint32_t capacity) in ds_htable_realloc() argument
36 table->buckets = ds_htable_reallocate_buckets(table, capacity); in ds_htable_realloc()
37 table->lookup = ds_htable_reallocate_lookup(table->lookup, capacity); in ds_htable_realloc()
38 table->capacity = capacity; in ds_htable_realloc()
43 const uint32_t mask = table->capacity - 1; in ds_htable_rehash()
48 table->min_deleted = table->capacity; in ds_htable_rehash()
108 table->min_deleted = table->capacity; in ds_htable_pack()
114 const uint32_t capacity = table->capacity; in ds_htable_auto_truncate() local
116 if (table->size <= (capacity / 4) && (capacity / 2) >= DS_HTABLE_MIN_CAPACITY) { in ds_htable_auto_truncate()
118 ds_htable_realloc(table, capacity / 2); in ds_htable_auto_truncate()
123 static ds_htable_t *ds_htable_with_capacity(uint32_t capacity) in ds_htable_with_capacity() argument
127 table->buckets = ds_htable_allocate_buckets(capacity); in ds_htable_with_capacity()
128 table->lookup = ds_htable_allocate_lookup(capacity); in ds_htable_with_capacity()
129 table->capacity = capacity; in ds_htable_with_capacity()
130 table->min_deleted = capacity; in ds_htable_with_capacity()
149 memcpy(_dst->lookup, _src->lookup, _src->capacity * sizeof(uint32_t)); in ds_htable_copy()
164 dst->buckets = ds_htable_allocate_buckets(src->capacity); in ds_htable_clone()
165 dst->lookup = ds_htable_allocate_lookup(src->capacity); in ds_htable_clone()
166 dst->capacity = src->capacity; in ds_htable_clone()
490 table->min_deleted = table->capacity; in ds_htable_clear_buffer()
497 if (table->capacity > DS_HTABLE_MIN_CAPACITY) { in ds_htable_clear()
503 table->min_deleted = table->capacity; in ds_htable_clear()
619 ds_htable_realloc(table, table->capacity << 1); in ds_htable_increase_capacity()
628 void ds_htable_ensure_capacity(ds_htable_t *table, uint32_t capacity) in ds_htable_ensure_capacity() argument
630 capacity = ds_htable_get_capacity_for_size(capacity); in ds_htable_ensure_capacity()
632 if (capacity > table->capacity) { in ds_htable_ensure_capacity()
633 ds_htable_realloc(table, capacity); in ds_htable_ensure_capacity()
646 DS_HTABLE_BUCKET_REHASH(table, next, table->capacity - 1, table->next); in ds_htable_put_distinct_bucket()
651 if (table->next == table->capacity) { in ds_htable_put_distinct_bucket()
665 DS_HTABLE_BUCKET_REHASH(table, bucket, table->capacity - 1, table->next); in ds_htable_init_next_bucket()
689 if (table->next == table->capacity) { in ds_htable_lookup_or_next()
957 ds_htable_t *mapped = ds_htable_with_capacity(table->capacity); in ds_htable_map()
983 ds_htable_t *filtered = ds_htable_with_capacity(table->capacity); in ds_htable_filter()
1004 ds_htable_t *filtered = ds_htable_with_capacity(table->capacity); in ds_htable_filter_callback()
1146 ds_htable_t *reversed = ds_htable_with_capacity(table->capacity); in ds_htable_reversed()
1151 const uint32_t mask = reversed->capacity - 1; in ds_htable_reversed()