PengZheng commented on code in PR #721: URL: https://github.com/apache/celix/pull/721#discussion_r1469136013
########## libs/utils/include/celix_array_list.h: ########## @@ -157,10 +172,27 @@ CELIX_DEFINE_AUTOPTR_CLEANUP_FUNC(celix_array_list_t, celix_arrayList_destroy) CELIX_UTILS_EXPORT int celix_arrayList_size(const celix_array_list_t *list); +/** + * @brief Create a shallow copy of the array list. + * + * The returned array list will be a shallow copy of the provided array list. + * If the entries are pointers, the pointers will be copied, but the pointed to values will not be copied. + * The equals callback provided when the provided array list was created will be copied, the removed callback + * will not be copied. Review Comment: Yes, reference counting will increase overall complexity and I am not a big fans of it. And I agree that shallow copy could be used as implementation details for ArrayList of trivial types, if `celix_arrayList_copy` is not exposed to users AND appropriate type checking is in place (check following comments for more details). Unfortunately, shallow copy is also applied to ArrayList of non-trivial types (Strings and Versions), which will lead to error prone APIs. I would expect lots of use-after-free bugs from such API. Reference counting just seems like a workable solution. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org