diff --git a/src/xrt/auxiliary/util/u_string_list.cpp b/src/xrt/auxiliary/util/u_string_list.cpp index 077c835c9..cd1bcfcb5 100644 --- a/src/xrt/auxiliary/util/u_string_list.cpp +++ b/src/xrt/auxiliary/util/u_string_list.cpp @@ -47,6 +47,17 @@ u_string_list_create_with_capacity(uint32_t capacity) } } +struct u_string_list * +u_string_list_create_from_list(struct u_string_list *usl) +{ + try { + auto ret = std::make_unique(xrt::auxiliary::util::StringList{usl->list}); + return ret.release(); + } catch (std::exception const &) { + return nullptr; + } +} + uint32_t u_string_list_get_size(const struct u_string_list *usl) diff --git a/src/xrt/auxiliary/util/u_string_list.h b/src/xrt/auxiliary/util/u_string_list.h index 9c70d1986..af494f382 100644 --- a/src/xrt/auxiliary/util/u_string_list.h +++ b/src/xrt/auxiliary/util/u_string_list.h @@ -40,6 +40,14 @@ u_string_list_create(void); struct u_string_list * u_string_list_create_with_capacity(uint32_t capacity); +/*! + * @brief Create a new string list from an existing string list. + * + * @public @memberof u_string_list + */ +struct u_string_list * +u_string_list_create_from_list(struct u_string_list *usl); + /*! * @brief Retrieve the number of elements in the list *