/** * Destroy slist container auxiliary function. */ void _slist_destroy_auxiliary(slist_t* pslist_slist) { _slistnode_t* pt_node = NULL; bool_t b_result = false; /* test the pslist_slist is valid */ assert(pslist_slist != NULL); assert(_slist_is_inited(pslist_slist) || _slist_is_created(pslist_slist)); /* _alloc_deallocate all nodes in slist */ while (pslist_slist->_t_head._pt_next != NULL) { /* take out each node from the slist */ pt_node = pslist_slist->_t_head._pt_next; pslist_slist->_t_head._pt_next = pt_node->_pt_next; pt_node->_pt_next = NULL; /* destroy the node itself */ b_result = _GET_SLIST_TYPE_SIZE(pslist_slist); _GET_SLIST_TYPE_DESTROY_FUNCTION(pslist_slist)(pt_node->_pby_data, &b_result); assert(b_result); _alloc_deallocate(&pslist_slist->_t_allocator, pt_node, _SLIST_NODE_SIZE(_GET_SLIST_TYPE_SIZE(pslist_slist)), 1); pt_node = NULL; } /* _alloc_deallocate the allocator */ _alloc_destroy(&pslist_slist->_t_allocator); }
/** * Destroy data, the data type and slist element data type are same. */ void _slist_destroy_varg_value_auxiliary(slist_t* pslist_slist, _slistnode_t* pt_node) { bool_t b_result = false; assert(pslist_slist != NULL); assert(pt_node != NULL); assert(_slist_is_inited(pslist_slist) || _slist_is_created(pslist_slist)); b_result = _GET_SLIST_TYPE_SIZE(pslist_slist); _GET_SLIST_TYPE_DESTROY_FUNCTION(pslist_slist)(pt_node->_pby_data, &b_result); assert(b_result); }