36 lines
1.3 KiB
Diff
36 lines
1.3 KiB
Diff
From 7d5a0fa22f939891195da7193f2f092425663275 Mon Sep 17 00:00:00 2001
|
|
From: Imagination Technologies <powervr@imgtec.com>
|
|
Date: Thu, 15 Sep 2022 18:31:06 -0500
|
|
Subject: [PATCH 077/168] 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>
|
|
---
|
|
src/util/u_dynarray.h | 10 ++++++++++
|
|
1 file changed, 10 insertions(+)
|
|
|
|
diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h
|
|
index 6f91b820892..b41b0d4b032 100644
|
|
--- a/src/util/u_dynarray.h
|
|
+++ b/src/util/u_dynarray.h
|
|
@@ -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))
|
|
--
|
|
2.17.1
|
|
|