1 /****************************************************************************
5 * Generic list support for FreeType (specification).
7 * Copyright (C) 1996-2023 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
19 /**************************************************************************
21 * This file implements functions relative to list processing. Its data
22 * structures are defined in `freetype.h`.
31 #include <freetype/freetype.h>
34 #error "freetype.h of FreeType 1 has been loaded!"
35 #error "Please fix the directory search order for header files"
36 #error "so that freetype.h of FreeType 2 is found first."
43 /**************************************************************************
52 * Simple management of lists.
55 * This section contains various definitions related to list processing
56 * using doubly-linked nodes.
77 /**************************************************************************
83 * Find the list node for a given listed object.
87 * A pointer to the parent list.
89 * The address of the listed object.
92 * List node. `NULL` if it wasn't found.
94 FT_EXPORT( FT_ListNode )
95 FT_List_Find( FT_List list,
99 /**************************************************************************
105 * Append an element to the end of a list.
109 * A pointer to the parent list.
111 * The node to append.
114 FT_List_Add( FT_List list,
118 /**************************************************************************
124 * Insert an element at the head of a list.
128 * A pointer to parent list.
130 * The node to insert.
133 FT_List_Insert( FT_List list,
137 /**************************************************************************
143 * Remove a node from a list. This function doesn't check whether the
144 * node is in the list!
148 * The node to remove.
152 * A pointer to the parent list.
155 FT_List_Remove( FT_List list,
159 /**************************************************************************
165 * Move a node to the head/top of a list. Used to maintain LRU lists.
169 * A pointer to the parent list.
174 FT_List_Up( FT_List list,
178 /**************************************************************************
184 * An FT_List iterator function that is called during a list parse by
189 * The current iteration list node.
192 * A typeless pointer passed to @FT_List_Iterate. Can be used to point
193 * to the iteration's state.
196 (*FT_List_Iterator)( FT_ListNode node,
200 /**************************************************************************
206 * Parse a list and calls a given iterator function on each element.
207 * Note that parsing is stopped as soon as one of the iterator calls
208 * returns a non-zero value.
212 * A handle to the list.
214 * An iterator function, called on each node of the list.
216 * A user-supplied field that is passed as the second argument to the
220 * The result (a FreeType error code) of the last iterator call.
222 FT_EXPORT( FT_Error )
223 FT_List_Iterate( FT_List list,
224 FT_List_Iterator iterator,
228 /**************************************************************************
234 * An @FT_List iterator function that is called during a list
235 * finalization by @FT_List_Finalize to destroy all elements in a given
240 * The current system object.
243 * The current object to destroy.
246 * A typeless pointer passed to @FT_List_Iterate. It can be used to
247 * point to the iteration's state.
250 (*FT_List_Destructor)( FT_Memory memory,
255 /**************************************************************************
261 * Destroy all elements in the list as well as the list itself.
265 * A handle to the list.
268 * A list destructor that will be applied to each element of the list.
269 * Set this to `NULL` if not needed.
272 * The current memory object that handles deallocation.
275 * A user-supplied field that is passed as the last argument to the
279 * This function expects that all nodes added by @FT_List_Add or
280 * @FT_List_Insert have been dynamically allocated.
283 FT_List_Finalize( FT_List list,
284 FT_List_Destructor destroy,
293 #endif /* FTLIST_H_ */