mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-27 19:40:38 +02:00
mesa/util: add new util_dynarray_delete_unordered helper
This helper function will be used for managing dynamic arrays of resident texture/image handles. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
parent
5f249b9f05
commit
30471eb745
1 changed files with 14 additions and 0 deletions
|
|
@ -138,6 +138,20 @@ util_dynarray_trim(struct util_dynarray *buf)
|
|||
for (type *elem = (type *)(buf)->data; \
|
||||
elem < (type *)((char *)(buf)->data + (buf)->size); elem++)
|
||||
|
||||
#define util_dynarray_delete_unordered(buf, type, v) \
|
||||
do { \
|
||||
unsigned num_elements = (buf)->size / sizeof(type); \
|
||||
unsigned i; \
|
||||
for (i = 0; i < num_elements; i++) { \
|
||||
type __v = *util_dynarray_element((buf), type, (i)); \
|
||||
if (v == __v) { \
|
||||
memcpy(util_dynarray_element((buf), type, (i)), \
|
||||
util_dynarray_pop_ptr((buf), type), sizeof(type)); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue