72 struct cx_list_class_s { |
72 struct cx_list_class_s { |
73 /** |
73 /** |
74 * Destructor function. |
74 * Destructor function. |
75 * |
75 * |
76 * Implementations SHALL invoke the content destructor functions if provided |
76 * Implementations SHALL invoke the content destructor functions if provided |
77 * and SHALL deallocate the list memory. |
77 * and SHALL deallocate the entire list memory. |
78 */ |
78 */ |
79 cx_attr_nonnull |
79 cx_attr_nonnull |
80 void (*destructor)(struct cx_list_s *list); |
80 void (*deallocate)(struct cx_list_s *list); |
81 |
81 |
82 /** |
82 /** |
83 * Member function for inserting a single element. |
83 * Member function for inserting a single element. |
84 * Implementors SHOULD see to performant implementations for corner cases. |
84 * Implementors SHOULD see to performant implementations for corner cases. |
85 */ |
85 */ |
880 ); |
880 ); |
881 |
881 |
882 /** |
882 /** |
883 * Deallocates the memory of the specified list structure. |
883 * Deallocates the memory of the specified list structure. |
884 * |
884 * |
885 * Also calls content a destructor function, depending on the configuration |
885 * Also calls the content destructor function for each element, if specified. |
886 * in CxList.content_destructor_type. |
886 * |
887 * |
887 * @param list the list which shall be freed |
888 * This function itself is a destructor function for the CxList. |
888 */ |
889 * |
889 static inline void cxListFree(CxList *list) { |
890 * @param list the list which shall be destroyed |
|
891 */ |
|
892 static inline void cxListDestroy(CxList *list) { |
|
893 if (list == NULL) return; |
890 if (list == NULL) return; |
894 list->cl->destructor(list); |
891 list->cl->deallocate(list); |
895 } |
892 } |
896 |
893 |
897 /** |
894 /** |
898 * A shared instance of an empty list. |
895 * A shared instance of an empty list. |
899 * |
896 * |