util/idalloc: fold the size call into init
It's required, otherwise idalloc would fail. v2: renamed util_idalloc_(mt_)init param initial_num_ids (Pierre-Eric) Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> (v1) Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493>
This commit is contained in:
@@ -37,9 +37,11 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
util_idalloc_init(struct util_idalloc *buf)
|
||||
util_idalloc_init(struct util_idalloc *buf, unsigned initial_num_ids)
|
||||
{
|
||||
memset(buf, 0, sizeof(*buf));
|
||||
assert(initial_num_ids);
|
||||
util_idalloc_resize(buf, DIV_ROUND_UP(initial_num_ids, 32));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -103,15 +105,12 @@ util_idalloc_reserve(struct util_idalloc *buf, unsigned id)
|
||||
|
||||
void
|
||||
util_idalloc_mt_init(struct util_idalloc_mt *buf,
|
||||
unsigned initial_num_elements, bool skip_zero)
|
||||
unsigned initial_num_ids, bool skip_zero)
|
||||
{
|
||||
simple_mtx_init(&buf->mutex, mtx_plain);
|
||||
util_idalloc_init(&buf->buf);
|
||||
util_idalloc_init(&buf->buf, initial_num_ids);
|
||||
buf->skip_zero = skip_zero;
|
||||
|
||||
if (initial_num_elements)
|
||||
util_idalloc_resize(&buf->buf, DIV_ROUND_UP(initial_num_elements, 32));
|
||||
|
||||
if (skip_zero) {
|
||||
ASSERTED unsigned zero = util_idalloc_alloc(&buf->buf);
|
||||
assert(zero == 0);
|
||||
|
Reference in New Issue
Block a user