array deep clone

This commit is contained in:
fengzero
2023-10-26 09:44:54 +00:00
parent 920c0ade01
commit 4b98edef12
+11
View File
@@ -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