@@ -38,9 +38,11 @@ The naming scheme used for the object struct is `<celix_object_name>`, typically
3838` <celix_object_name>_t ` . For the object functions, the following naming scheme is
3939used: ` <celix_objectName>_<functionName> ` . Note the camelCase for the object name and function name.
4040
41- An Apache Celix C object should always have a create and a destroy function. The create function is used to create
42- a new object, and the destroy function is used to destroy the object. The destroy function should also free the
43- object's memory.
41+ An Apache Celix C object should always have a constructor and a destructor. If memory allocation is involved,
42+ a ` celix_<objectName>_create ` function is used to create and return a new object, and a ` celix_<objectName>_destroy `
43+ function is used to destroy the object and free the object's memory. Otherwise, use a ` celix_<objectName>_init ` function
44+ with ` celix_status_t ` return value to initialize the object's provided memory and use a ` celix_<objectName>_deinit `
45+ function to deinitialize the object. The ` celix_<objectName>_deinit ` function should not free the object's memory.
4446
4547An Apache Celix C object can also have additional functions to access object information or to manipulate the object.
4648If an object contains properties, it should provide a getter and setter function for each property.
@@ -53,8 +55,8 @@ different element types. Refer to the header files for more information.
5355
5456## Apache Celix C Scope-Based Resource Management
5557
56- Apache Celix offers several macros to support scope-based resource management (SBRM). These macros are
57- inspired by [ Scoped-based Resource Management for the Kernel] ( https://lwn.net/Articles/934838/ ) .
58+ Apache Celix offers several macros to add support for scope-based resource management (SBRM) to existing types.
59+ These macros are inspired by [ Scoped-based Resource Management for the Kernel] ( https://lwn.net/Articles/934838/ ) .
5860
5961The main macros used for SBRM are:
6062- ` celix_autofree ` : Automatically frees memory with ` free ` when the variable goes out of scope.
@@ -65,13 +67,14 @@ The main macros used for SBRM are:
6567
6668These macros can be found in the Apache Celix utils headers ` celix_cleanup.h ` and ` celix_stdlib_cleanup.h ` .
6769
68- In Apache Celix, C objects must opt into SBRM. This is done by using a "define" macro, which determines the
70+ In Apache Celix, C objects must opt into SBRM. This is done by using a ` CELIX_DEFINE_AUTO ` macro, which determines the
6971expected C functions to clean up the object.
7072
7173## Support for Resource Allocation Is Initialization (RAII)-like Structures
7274
73- Based on the previously mentioned SBRM, Apache Celix also offers support for structures that resemble RAII. These can be
74- used to guard locks, manage service registration, etc. Support for RAII-like structures is facilitated by providing
75+ Based on the previously mentioned SBRM, Apache Celix also offers support for structures that resemble RAII.
76+ These can be used to guard locks, manage service registration, etc. These guards should follow the naming convention
77+ ` celix_<obj_to_guard>_guard_t ` . Support for RAII-like structures is facilitated by providing
7578additional cleanup functions that work with either the ` celix_auto ` or ` celix_autoptr ` macros.
7679
7780Examples include:
0 commit comments