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:
Marek Olšák 2020-09-30 13:44:52 -04:00 committed by Marge Bot
parent 155b1b1792
commit 72fa3372cc
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}