PengZheng commented on code in PR #591: URL: https://github.com/apache/celix/pull/591#discussion_r1271665912
########## libs/utils/include/celix_array_list.h: ########## @@ -148,6 +149,8 @@ celix_array_list_t* celix_arrayList_createWithOptions(const celix_array_list_cre CELIX_UTILS_EXPORT void celix_arrayList_destroy(celix_array_list_t *list); +CELIX_DEFINE_AUTOPTR_CLEANUP_FUNC(celix_array_list_t, celix_arrayList_destroy) Review Comment: > Maybe in the case for array list, hash maps, etc we should introduce a _retain and _release function and couple the celix_autoptr. In this case the get a something akin to shared_ptr. Reference couting has non-negligible overhead. Most of the time, `celix_autoptr` is like `unique_ptr` more than `shared_ptr`. In this case, `CELIX_DEFINE_AUTOPTR_CLEANUP_FUNC(celix_array_list_t, celix_arrayList_destroy)` is only intended to associate dtor to autoptr, which we must do it manually. It is nearly zero-overhead just like `unique_ptr`. Sometimes it is used with reference count like the following: https://github.com/apache/celix/pull/591/commits/fc25847a213d4a36e5882793c0674ae423e46da9#diff-9be07887dc8325bf3802ded6a943d9a42b1dae30ea4c092013b78cf19615f2e9R67 Other times, we use it in an ad hoc way like `gsl::finally`: https://github.com/apache/celix/pull/591/files#diff-e659faa3a3268b42f6fe5bc36d506cb6beb651b3d5688bfe0ba93dbcf3f1e534R92 -- 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