From 4b98edef12e54ead0e7e78044b4a1b0ab0d7046e Mon Sep 17 00:00:00 2001 From: fengzero Date: Thu, 26 Oct 2023 03:16:48 +0000 Subject: [PATCH] array deep clone --- include/neuron/utils/utextend.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/neuron/utils/utextend.h b/include/neuron/utils/utextend.h index dde01cb9..ef406c9a 100644 --- a/include/neuron/utils/utextend.h +++ b/include/neuron/utils/utextend.h @@ -75,4 +75,15 @@ static inline void *utarray_steal(UT_array *array) for ((el) = (head); (el) != NULL; (el) = DECLTYPE(el)((el)->hh.next)) #endif +static inline UT_array *utarray_deep_clone(UT_array *array) +{ + UT_array *result = NULL; + + utarray_new(result, &array->icd); + + utarray_foreach(array, void *, elem) { utarray_push_back(result, elem); } + + return result; +} + #endif