ReactOS 0.4.15-dev-7934-g1dc8d80
dict.c
Go to the documentation of this file.
1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30/*
31** Author: Eric Veach, July 1994.
32**
33*/
34
35//#include <stddef.h>
36#include "dict-list.h"
37#include "memalloc.h"
38
39/* really __gl_dictListNewDict */
40Dict *dictNewDict( void *frame,
41 int (*leq)(void *frame, DictKey key1, DictKey key2) )
42{
43 Dict *dict = (Dict *) memAlloc( sizeof( Dict ));
45
46 if (dict == NULL) return NULL;
47
48 head = &dict->head;
49
50 head->key = NULL;
51 head->next = head;
52 head->prev = head;
53
54 dict->frame = frame;
55 dict->leq = leq;
56
57 return dict;
58}
59
60/* really __gl_dictListDeleteDict */
61void dictDeleteDict( Dict *dict )
62{
64
65 for( node = dict->head.next; node != &dict->head; node = next ) {
66 next = node->next;
67 memFree( node );
68 }
69 memFree( dict );
70}
71
72/* really __gl_dictListInsertBefore */
74{
75 DictNode *newNode;
76
77 do {
78 node = node->prev;
79 } while( node->key != NULL && ! (*dict->leq)(dict->frame, node->key, key));
80
81 newNode = (DictNode *) memAlloc( sizeof( DictNode ));
82 if (newNode == NULL) return NULL;
83
84 newNode->key = key;
85 newNode->next = node->next;
86 node->next->prev = newNode;
87 newNode->prev = node;
88 node->next = newNode;
89
90 return newNode;
91}
92
93/* really __gl_dictListDelete */
94void dictDelete( Dict *dict, DictNode *node ) /*ARGSUSED*/
95{
96 node->next->prev = node->prev;
97 node->prev->next = node->next;
98 memFree( node );
99}
100
101/* really __gl_dictListSearch */
103{
104 DictNode *node = &dict->head;
105
106 do {
107 node = node->next;
108 } while( node->key != NULL && ! (*dict->leq)(dict->frame, key, node->key));
109
110 return node;
111}
struct outqueuenode * head
Definition: adnsresfilter.c:66
#define dictDeleteDict(dict)
Definition: dict-list.h:45
#define dictSearch(dict, key)
Definition: dict-list.h:47
#define dictDelete(dict, node)
Definition: dict-list.h:50
#define dictInsertBefore(dict, node, key)
Definition: dict-list.h:49
#define dictNewDict(frame, leq)
Definition: dict-list.h:44
#define NULL
Definition: types.h:112
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: glext.h:10608
#define memAlloc
Definition: memalloc.h:48
#define memFree
Definition: memalloc.h:41
static unsigned __int64 next
Definition: rand_nt.c:6
DictNode * prev
Definition: dict-list.h:91
DictKey key
Definition: dict-list.h:89
DictNode * next
Definition: dict-list.h:90
Definition: dict-list.h:94
DictNode head
Definition: dict-list.h:95
int(* leq)(void *frame, DictKey key1, DictKey key2)
Definition: dict-list.h:97
void * frame
Definition: dict-list.h:96
Definition: copy.c:22
Definition: dlist.c:348
void * next
Definition: dlist.c:360