PengZheng commented on PR #591:
URL: https://github.com/apache/celix/pull/591#issuecomment-1658467319

   > The cleanup macros are IMO only really valuable during object creation / 
initiation and RAII-based guard object. @PengZheng do you agree?
   
   Yes, this should be made explicit in our documentation.
   
   > C Objects should define a cleanup function and
   
   > Provide a celix_<myObj>_create or celix_<myObj>_init function. The latter 
is used when no memory allocation is needed. The create function returns a 
pointer (possible NULL) and the _init returns a celix_status_t or a struct by 
value.
   > Provide a celix_<myObj>_destroy or celix_<myObj>_deinit function. The 
latter is used when no memory needs to be deallocated.
   > If the structure "guards" a condition for a scope (lock guard, service 
registration guard, etc) it should use the naming convention 
celix_<obj_to_guard>_guard_t (so celix_file_guard_t, or 
celix_threadMutex_guard_t
   
   There are two usage pattern with different semantics:
   
   1. Modify existing types to add autocleanup. Examples include 
`celix_auto(celix_fd_t)` /`celix_autoptr(celix_string_hash_map_t)`
   2. Introduce new type to perform specific actions 
(`celix_mutex_lock_guard_t`) or to capture cleanup context 
(`celix_service_registration_guard_t`)
   
   It is the second pattern to which the naming convention applies. I have 
updated all such usages to the suggested naming convention. 


-- 
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

Reply via email to