mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-17 09:10:16 +01:00
util/dynarray: Add an append_array helper
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19685>
This commit is contained in:
parent
db0e6f9a07
commit
b67fdcdfbc
1 changed files with 10 additions and 0 deletions
|
|
@ -168,6 +168,16 @@ util_dynarray_trim(struct util_dynarray *buf)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
util_dynarray_append_dynarray(struct util_dynarray *buf,
|
||||
const struct util_dynarray *other)
|
||||
{
|
||||
if (other->size > 0) {
|
||||
void *p = util_dynarray_grow_bytes(buf, 1, other->size);
|
||||
memcpy(p, other->data, other->size);
|
||||
}
|
||||
}
|
||||
|
||||
#define util_dynarray_append(buf, type, v) do {type __v = (v); memcpy(util_dynarray_grow_bytes((buf), 1, sizeof(type)), &__v, sizeof(type));} while(0)
|
||||
/* Returns a pointer to the space of the first new element (in case of growth) or NULL on failure. */
|
||||
#define util_dynarray_resize(buf, type, nelts) util_dynarray_resize_bytes(buf, (nelts), sizeof(type))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue