ReactOS 0.4.15-dev-5664-g3bf4ef6
dictionary.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
Include dependency graph for dictionary.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef int(* comparefunc) (const void *a, const void *b, void *extra)
 
typedef void(* destroyfunc) (void *k, void *v, void *extra)
 
typedef BOOL(* enumeratefunc) (const void *k, const void *v, void *extra, void *closure)
 

Functions

struct dictionarydictionary_create (comparefunc c, destroyfunc d, void *extra) DECLSPEC_HIDDEN
 
void dictionary_destroy (struct dictionary *d) DECLSPEC_HIDDEN
 
UINT dictionary_num_entries (struct dictionary *d) DECLSPEC_HIDDEN
 
void dictionary_insert (struct dictionary *d, const void *k, const void *v) DECLSPEC_HIDDEN
 
BOOL dictionary_find (struct dictionary *d, const void *k, void **v) DECLSPEC_HIDDEN
 
void dictionary_remove (struct dictionary *d, const void *k) DECLSPEC_HIDDEN
 
void dictionary_enumerate (struct dictionary *d, enumeratefunc e, void *closure) DECLSPEC_HIDDEN
 

Typedef Documentation

◆ comparefunc

typedef int(* comparefunc) (const void *a, const void *b, void *extra)

Definition at line 35 of file dictionary.h.

◆ destroyfunc

typedef void(* destroyfunc) (void *k, void *v, void *extra)

Definition at line 40 of file dictionary.h.

◆ enumeratefunc

typedef BOOL(* enumeratefunc) (const void *k, const void *v, void *extra, void *closure)

Definition at line 45 of file dictionary.h.

Function Documentation

◆ dictionary_create()

struct dictionary * dictionary_create ( comparefunc  c,
destroyfunc  d,
void extra 
)

Definition at line 45 of file dictionary.c.

46{
47 struct dictionary *ret;
48
49 TRACE("(%p, %p, %p)\n", c, d, extra);
50 if (!c)
51 return NULL;
52 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dictionary));
53 if (ret)
54 {
55 ret->comp = c;
56 ret->destroy = d;
57 ret->extra = extra;
58 ret->head = NULL;
59 ret->num_entries = 0;
60 }
61 TRACE("returning %p\n", ret);
62 return ret;
63}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
const GLubyte * c
Definition: glext.h:8905
@ extra
Definition: id3.c:95
#define d
Definition: ke_i.h:81
#define c
Definition: ke_i.h:80
#define TRACE(s)
Definition: solgame.cpp:4
int ret

Referenced by PropertyStorage_CreateDictionaries().

◆ dictionary_destroy()

void dictionary_destroy ( struct dictionary d)

Definition at line 65 of file dictionary.c.

66{
67 TRACE("(%p)\n", d);
68 if (d)
69 {
70 struct dictionary_entry *p;
71
72 for (p = d->head; p; )
73 {
74 struct dictionary_entry *next = p->next;
75
76 if (d->destroy)
77 d->destroy(p->key, p->value, d->extra);
79 p = next;
80 }
82 }
83}
#define HeapFree(x, y, z)
Definition: compat.h:735
GLfloat GLfloat p
Definition: glext.h:8902
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: dictionary.c:30

Referenced by PropertyStorage_DestroyDictionaries(), and PropertyStorage_ReadFromStream().

◆ dictionary_enumerate()

void dictionary_enumerate ( struct dictionary d,
enumeratefunc  e,
void closure 
)

Definition at line 179 of file dictionary.c.

180{
181 struct dictionary_entry *p;
182
183 TRACE("(%p, %p, %p)\n", d, e, closure);
184 if (!d)
185 return;
186 if (!e)
187 return;
188 for (p = d->head; p; p = p->next)
189 if (!e(p->key, p->value, d->extra, closure))
190 break;
191}
#define e
Definition: ke_i.h:82
struct define * next
Definition: compiler.c:65

Referenced by create_EnumSTATPROPSTG(), PropertyStorage_WriteDictionaryToStream(), and PropertyStorage_WritePropertiesToStream().

◆ dictionary_find()

BOOL dictionary_find ( struct dictionary d,
const void k,
void **  v 
)

Definition at line 142 of file dictionary.c.

143{
144 struct dictionary_entry **prior;
145 BOOL ret = FALSE;
146
147 TRACE("(%p, %p, %p)\n", d, k, value);
148 if (!d)
149 return FALSE;
150 if (!value)
151 return FALSE;
152 if ((prior = dictionary_find_internal(d, k)))
153 {
154 *value = (*prior)->value;
155 ret = TRUE;
156 }
157 TRACE("returning %d (%p)\n", ret, *value);
158 return ret;
159}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static struct dictionary_entry ** dictionary_find_internal(struct dictionary *d, const void *k)
Definition: dictionary.c:95
unsigned int BOOL
Definition: ntddk_ex.h:94
int k
Definition: mpi.c:3369
Definition: pdh_main.c:94

Referenced by IPropertyStorage_fnDeleteMultiple(), IPropertyStorage_fnDeletePropertyNames(), prop_enum_copy_cb(), PropertyStorage_FindProperty(), PropertyStorage_FindPropertyByName(), and PropertyStorage_FindPropertyNameById().

◆ dictionary_insert()

void dictionary_insert ( struct dictionary d,
const void k,
const void v 
)

Definition at line 113 of file dictionary.c.

114{
115 struct dictionary_entry **prior;
116
117 TRACE("(%p, %p, %p)\n", d, k, v);
118 if (!d)
119 return;
120 if ((prior = dictionary_find_internal(d, k)))
121 {
122 if (d->destroy)
123 d->destroy((*prior)->key, (*prior)->value, d->extra);
124 (*prior)->key = (void *)k;
125 (*prior)->value = (void *)v;
126 }
127 else
128 {
130 sizeof(struct dictionary_entry));
131
132 if (!elem)
133 return;
134 elem->key = (void *)k;
135 elem->value = (void *)v;
136 elem->next = d->head;
137 d->head = elem;
138 d->num_entries++;
139 }
140}
const GLdouble * v
Definition: gl.h:2040
static size_t elem
Definition: string.c:68

Referenced by PropertyStorage_StoreNameWithId(), and PropertyStorage_StorePropWithId().

◆ dictionary_num_entries()

UINT dictionary_num_entries ( struct dictionary d)

Definition at line 85 of file dictionary.c.

86{
87 return d ? d->num_entries : 0;
88}

Referenced by IPropertyStorage_fnWriteMultiple(), PropertyStorage_WriteDictionaryToStream(), and PropertyStorage_WriteToStream().

◆ dictionary_remove()

void dictionary_remove ( struct dictionary d,
const void k 
)

Definition at line 161 of file dictionary.c.

162{
163 struct dictionary_entry **prior, *temp;
164
165 TRACE("(%p, %p)\n", d, k);
166 if (!d)
167 return;
168 if ((prior = dictionary_find_internal(d, k)))
169 {
170 temp = *prior;
171 if (d->destroy)
172 d->destroy((*prior)->key, (*prior)->value, d->extra);
173 *prior = (*prior)->next;
175 d->num_entries--;
176 }
177}
static calc_node_t temp
Definition: rpn_ieee.c:38
struct dictionary_entry * next
Definition: dictionary.c:33

Referenced by IPropertyStorage_fnDeleteMultiple(), and IPropertyStorage_fnDeletePropertyNames().