diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2018-08-13 14:41:19 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2018-08-22 14:41:26 -0700 |
commit | 7f8ecedced0e65b40850c5c450fd8c3a1f2f90d1 (patch) | |
tree | 514c54dfb32c3c8220532560f43238ddb015f134 /src/util/u_dynarray.h | |
parent | 61b84b8c14c90a394e64cfb4edfd94fb746203a8 (diff) |
util/dynarray: add a clone function
v2: Fix mem_ctx parameter type. (Thomas)
Reviewed-by: Thomas Helland <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/util/u_dynarray.h')
-rw-r--r-- | src/util/u_dynarray.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h index dcbbc06d161..6bea481d44b 100644 --- a/src/util/u_dynarray.h +++ b/src/util/u_dynarray.h @@ -102,6 +102,15 @@ util_dynarray_resize(struct util_dynarray *buf, unsigned newsize) return p; } +static inline void +util_dynarray_clone(struct util_dynarray *buf, void *mem_ctx, + struct util_dynarray *from_buf) +{ + util_dynarray_init(buf, mem_ctx); + util_dynarray_resize(buf, from_buf->size); + memcpy(buf->data, from_buf->data, from_buf->size); +} + static inline void * util_dynarray_grow(struct util_dynarray *buf, int diff) { |