Blender  V2.93
BLI_linklist.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
26 #include "BLI_compiler_attrs.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 struct BLI_mempool;
33 struct MemArena;
34 
35 typedef void (*LinkNodeFreeFP)(void *link);
36 typedef void (*LinkNodeApplyFP)(void *link, void *userdata);
37 
38 typedef struct LinkNode {
39  struct LinkNode *next;
40  void *link;
42 
49 typedef struct LinkNodePair {
52 
55 
58 
60 
61 void BLI_linklist_move_item(LinkNode **listp, int curr_index, int new_index) ATTR_NONNULL(1);
62 
63 void BLI_linklist_prepend_nlink(LinkNode **listp, void *ptr, LinkNode *nlink) ATTR_NONNULL(1, 3);
64 void BLI_linklist_prepend(LinkNode **listp, void *ptr) ATTR_NONNULL(1);
65 void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, struct MemArena *ma)
66  ATTR_NONNULL(1, 3);
67 void BLI_linklist_prepend_pool(LinkNode **listp, void *ptr, struct BLI_mempool *mempool)
68  ATTR_NONNULL(1, 3);
69 
70 /* use LinkNodePair to avoid full search */
71 void BLI_linklist_append_nlink(LinkNodePair *list_pair, void *ptr, LinkNode *nlink)
72  ATTR_NONNULL(1, 3);
73 void BLI_linklist_append(LinkNodePair *list_pair, void *ptr) ATTR_NONNULL(1);
74 void BLI_linklist_append_arena(LinkNodePair *list_pair, void *ptr, struct MemArena *ma)
75  ATTR_NONNULL(1, 3);
76 void BLI_linklist_append_pool(LinkNodePair *list_pair, void *ptr, struct BLI_mempool *mempool)
77  ATTR_NONNULL(1, 3);
78 
81  ATTR_NONNULL(1, 2);
82 void BLI_linklist_insert_after(LinkNode **listp, void *ptr) ATTR_NONNULL(1);
83 
84 void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc);
85 void BLI_linklist_freeN(LinkNode *list);
86 void BLI_linklist_free_pool(LinkNode *list, LinkNodeFreeFP freefunc, struct BLI_mempool *mempool);
87 void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata);
89  int (*cmp)(const void *, const void *)) ATTR_WARN_UNUSED_RESULT
90  ATTR_NONNULL(2);
92  int (*cmp)(void *, const void *, const void *),
93  void *thunk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2);
94 
95 #define BLI_linklist_prepend_alloca(listp, ptr) \
96  BLI_linklist_prepend_nlink(listp, ptr, alloca(sizeof(LinkNode)))
97 #define BLI_linklist_append_alloca(list_pair, ptr) \
98  BLI_linklist_append_nlink(list_pair, ptr, alloca(sizeof(LinkNode)))
99 
100 #ifdef __cplusplus
101 }
102 #endif
#define ATTR_NONNULL(...)
void BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() ATTR_WARN_UNUSED_RESULT
LinkNode * last_node
Definition: BLI_linklist.h:50
LinkNode * list
Definition: BLI_linklist.h:50
void * link
Definition: BLI_linklist.h:40
struct LinkNode * next
Definition: BLI_linklist.h:39
PointerRNA * ptr
Definition: wm_files.c:3157