1 /***************************************************************************/
5 /* Generic list support for FreeType (body). */
7 /* Copyright 1996-2001 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. */
16 /***************************************************************************/
18 /*************************************************************************/
20 /* This file implements functions relative to list processing. Its */
21 /* data structures are defined in `freetype/internal/ftlist.h'. */
23 /*************************************************************************/
28 #include FT_INTERNAL_DEBUG_H
29 #include FT_INTERNAL_OBJECTS_H
32 /*************************************************************************/
34 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
35 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
36 /* messages during execution. */
39 #define FT_COMPONENT trace_list
42 /* documentation is in ftlist.h */
44 FT_EXPORT_DEF( FT_ListNode )
45 FT_List_Find( FT_List list,
54 if ( cur->data == data )
60 return (FT_ListNode)0;
64 /* documentation is in ftlist.h */
67 FT_List_Add( FT_List list,
70 FT_ListNode before = list->tail;
85 /* documentation is in ftlist.h */
88 FT_List_Insert( FT_List list,
91 FT_ListNode after = list->head;
106 /* documentation is in ftlist.h */
108 FT_EXPORT_DEF( void )
109 FT_List_Remove( FT_List list,
112 FT_ListNode before, after;
119 before->next = after;
124 after->prev = before;
130 /* documentation is in ftlist.h */
132 FT_EXPORT_DEF( void )
133 FT_List_Up( FT_List list,
136 FT_ListNode before, after;
142 /* check whether we are already on top of the list */
146 before->next = after;
149 after->prev = before;
154 node->next = list->head;
155 list->head->prev = node;
160 /* documentation is in ftlist.h */
162 FT_EXPORT_DEF( FT_Error )
163 FT_List_Iterate( FT_List list,
164 FT_List_Iterator iterator,
167 FT_ListNode cur = list->head;
168 FT_Error error = FT_Err_Ok;
173 FT_ListNode next = cur->next;
176 error = iterator( cur, user );
187 /* documentation is in ftlist.h */
189 FT_EXPORT_DEF( void )
190 FT_List_Finalize( FT_List list,
191 FT_List_Destructor destroy,
201 FT_ListNode next = cur->next;
202 void* data = cur->data;
206 destroy( memory, data, user );