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