API参考
载入中...
搜索中...
未找到
list_base.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
20
21#ifndef LIST_BASE_H
22#define LIST_BASE_H
23
24#include "hitls_build.h"
25#ifdef HITLS_BSL_HASH
26
27#include <stdint.h>
28#include <stddef.h>
29#include <stdbool.h>
30#include "bsl_hash_list.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
41struct ListTagRawListNode {
42 struct ListTagRawListNode *next; /* points to the next node */
43 struct ListTagRawListNode *prev; /* points to the previous node */
44};
45
50typedef struct ListTagRawListNode ListRawNode;
51
56typedef struct {
57 ListRawNode head; /* list node */
58 /* Node memory release function, which needs to release nodes and other private resources on node */
59 ListFreeFunc freeFunc;
60} RawList;
61
66struct BslListSt {
67 RawList rawList; /* Linked list header */
68 ListDupFreeFuncPair dataFunc; /* used to store data */
69};
70
77struct BslListNodeSt {
78 ListRawNode rawNode;
79 uintptr_t userdata;
80};
81
96int32_t ListRawInit(RawList *list, ListFreeFunc freeFunc);
97
107int32_t ListRawClear(RawList *list);
108
118int32_t ListRawDeinit(RawList *list);
119
128bool ListRawEmpty(const RawList *list);
129
137size_t ListRawSize(const RawList *list);
138
146int32_t ListRawPushFront(RawList *list, ListRawNode *node);
147
155int32_t ListRawPushBack(RawList *list, ListRawNode *node);
156
164int32_t ListRawInsert(const ListRawNode *curNode, ListRawNode *newNode);
165
175int32_t ListRawPopFront(RawList *list);
176
186int32_t ListRawPopBack(RawList *list);
187
200int32_t ListRawRemove(RawList *list, ListRawNode *node);
201
213ListRawNode *ListRawFront(const RawList *list);
214
226ListRawNode *ListRawBack(const RawList *list);
227
240ListRawNode *ListRawGetPrev(const RawList *list, const ListRawNode *node);
241
254ListRawNode *ListRawGetNext(const RawList *list, const ListRawNode *node);
255
276ListRawNode *ListRawFindNode(const RawList *list, ListMatchFunc nodeMatchFunc, uintptr_t data);
277
291#define BSL_CONTAINER_OF(ptr, type, member) \
292 ((type *)((uintptr_t)(ptr) - (uintptr_t)(&(((type *)0)->member))))
293
294#ifdef __cplusplus
295}
296#endif
297
298#endif /* HITLS_BSL_HASH */
299
300#endif // LIST_BASE_H