The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/qat/qat_api/common/ctrl/sal_list.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* SPDX-License-Identifier: BSD-3-Clause */
    2 /* Copyright(c) 2007-2022 Intel Corporation */
    3 /* $FreeBSD$ */
    4 /**
    5  *****************************************************************************
    6  * @file sal_list.c
    7  *
    8  * @ingroup SalCtrl
    9  *
   10  * List implementations for SAL
   11  *
   12  *****************************************************************************/
   13 
   14 #include "lac_mem.h"
   15 #include "lac_list.h"
   16 
   17 CpaStatus
   18 SalList_add(sal_list_t **list, sal_list_t **tail, void *pObj)
   19 {
   20         sal_list_t *new_element = NULL;
   21 
   22         if (NULL == *list) {
   23                 /* First element in list */
   24                 *list = malloc(sizeof(sal_list_t), M_QAT, M_WAITOK);
   25                 (*list)->next = NULL;
   26                 (*list)->pObj = pObj;
   27                 *tail = *list;
   28         } else {
   29                 /* add to tail of the list */
   30                 new_element = malloc(sizeof(sal_list_t), M_QAT, M_WAITOK);
   31                 new_element->pObj = pObj;
   32                 new_element->next = NULL;
   33 
   34                 (*tail)->next = new_element;
   35 
   36                 *tail = new_element;
   37         }
   38 
   39         return CPA_STATUS_SUCCESS;
   40 }
   41 
   42 void *
   43 SalList_getObject(sal_list_t *list)
   44 {
   45         if (list == NULL) {
   46                 return NULL;
   47         }
   48 
   49         return list->pObj;
   50 }
   51 
   52 void
   53 SalList_delObject(sal_list_t **list)
   54 {
   55         if (*list == NULL) {
   56                 return;
   57         }
   58 
   59         (*list)->pObj = NULL;
   60         return;
   61 }
   62 
   63 void *
   64 SalList_next(sal_list_t *list)
   65 {
   66         return list->next;
   67 }
   68 
   69 void
   70 SalList_free(sal_list_t **list)
   71 {
   72         sal_list_t *next_element = NULL;
   73         void *pObj = NULL;
   74         while (NULL != (*list)) {
   75                 next_element = SalList_next(*list);
   76                 pObj = SalList_getObject((*list));
   77                 LAC_OS_FREE(pObj);
   78                 LAC_OS_FREE(*list);
   79                 *list = next_element;
   80         }
   81 }
   82 
   83 void
   84 SalList_del(sal_list_t **head_list, sal_list_t **pre_list, sal_list_t *list)
   85 {
   86         void *pObj = NULL;
   87         if ((NULL == *head_list) || (NULL == *pre_list) || (NULL == list)) {
   88                 return;
   89         }
   90         if (*head_list == list) { /* delete the first node in list */
   91                 *head_list = list->next;
   92         } else {
   93                 (*pre_list)->next = list->next;
   94         }
   95         pObj = SalList_getObject(list);
   96         LAC_OS_FREE(pObj);
   97         LAC_OS_FREE(list);
   98         return;
   99 }

Cache object: 5db4a5b98c6870575a75e36dc0433f65


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.