1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 /** 4 *************************************************************************** 5 * @file lac_list.h 6 * 7 * @defgroup SalList 8 * 9 * @ingroup SalCtrl 10 * 11 * List structure and list functions. 12 * 13 ***************************************************************************/ 14 15 #ifndef LAC_LIST_H 16 #define LAC_LIST_H 17 18 /** 19 ***************************************************************************** 20 * @ingroup SalList 21 * 22 * @description 23 * List structure 24 * 25 *****************************************************************************/ 26 typedef struct sal_list_s { 27 28 struct sal_list_s *next; 29 void *pObj; 30 31 } sal_list_t; 32 33 /** 34 ******************************************************************************* 35 * @ingroup SalList 36 * Add a structure to tail of a list. 37 * 38 * @description 39 * Adds pObj to the tail of list (if it exists). Allocates and sets a 40 * new sal_list_t structure. 41 * 42 * @param[in] list Pointer to the head pointer of the list. 43 * Can be NULL if no elements yet in list. 44 * @param[in/out] tail Pointer to tail pointer of the list. 45 * Can be NULL if no elements yet in list. 46 * Is updated by the function to point to 47 *tail 48 * of list if pObj has been successfully 49 *added. 50 * @param[in] pObj Pointer to structure to add to tail of 51 * the list. 52 * @retval status 53 * 54 *****************************************************************************/ 55 CpaStatus SalList_add(sal_list_t **list, sal_list_t **tail, void *pObj); 56 57 /** 58 ******************************************************************************* 59 * @ingroup SalList 60 * Delete an element from the list. 61 * 62 * @description 63 * Delete an element from the list. 64 * 65 * @param[in/out] head_list Pointer to the head pointer of the list. 66 * Can be NULL if no elements yet in list. 67 * Is updated by the function 68 * to point to list->next if head_list is 69 *list. 70 * @param[in/out] pre_list Pointer to the previous pointer of the 71 *list. 72 * Can be NULL if no elements yet in list. 73 * (*pre_list)->next is updated 74 * by the function to point to list->next 75 * @param[in] list Pointer to list. 76 * 77 *****************************************************************************/ 78 void 79 SalList_del(sal_list_t **head_list, sal_list_t **pre_list, sal_list_t *list); 80 81 /** 82 ******************************************************************************* 83 * @ingroup SalList 84 * Returns pObj element in list structure. 85 * 86 * @description 87 * Returns pObj associated with sal_list_t structure. 88 * 89 * @param[in] list Pointer to list element. 90 * @retval void* pObj member of list structure. 91 * 92 *****************************************************************************/ 93 void *SalList_getObject(sal_list_t *list); 94 95 /** 96 ******************************************************************************* 97 * @ingroup SalList 98 * Set pObj to be NULL in the list. 99 * 100 * @description 101 * Set pObj of a element in the list to be NULL. 102 * 103 * @param[in] list Pointer to list element. 104 * 105 *****************************************************************************/ 106 void SalList_delObject(sal_list_t **list); 107 108 /** 109 ******************************************************************************* 110 * @ingroup SalList 111 * Returns next element in list structure. 112 * 113 * @description 114 * Returns next associated with sal_list_t structure. 115 * 116 * @param[in] list Pointer to list element. 117 * @retval void* next member of list structure. 118 * 119 *****************************************************************************/ 120 void *SalList_next(sal_list_t *); 121 122 /** 123 ******************************************************************************* 124 * @ingroup SalList 125 * Frees memory associated with list structure. 126 * 127 * @description 128 * Frees memory associated with list structure and the Obj pointed to by 129 * the list. 130 * 131 * @param[in] list Pointer to list. 132 * 133 *****************************************************************************/ 134 void SalList_free(sal_list_t **); 135 136 #endif 137