util/idalloc: resize if ID is too large for reservation
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7031>
This commit is contained in:
parent
155b1b1792
commit
72fa3372cc
|
@ -103,7 +103,8 @@ util_idalloc_free(struct util_idalloc *buf, unsigned id)
|
|||
void
|
||||
util_idalloc_reserve(struct util_idalloc *buf, unsigned id)
|
||||
{
|
||||
assert(id < buf->num_elements);
|
||||
if (id >= buf->num_elements)
|
||||
util_idalloc_resize(buf, id * 2);
|
||||
assert((buf->data[id / 32] & (1u << (id % 32))) == 0);
|
||||
buf->data[id / 32] |= 1u << (id % 32);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue