ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/dlink.C
(Generate patch)

Comparing cvsroot/ermyth/src/dlink.C (file contents):
Revision 1.3 by pippijn, Sat Jul 21 13:23:21 2007 UTC vs.
Revision 1.4 by pippijn, Tue Aug 28 17:08:12 2007 UTC

1/* 1/*
2 * dlink.C: Linked lists. 2 * dlink.C: Linked lists.
3 * Rights to this code are documented in doc/pod/license.pod. 3 * Rights to this code are documented in doc/pod/license.pod.
4 * 4 *
5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) 5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 */ 6 */
7 7
8static char const rcsid[] = "$Id: dlink.C,v 1.3 2007/07/21 13:23:21 pippijn Exp $"; 8static char const rcsid[] = "$Id: dlink.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $";
9 9
10#include "atheme.h" 10#include "atheme.h"
11#include "internal.h" 11#include "internal.h"
12 12
13static BlockHeap *node_heap;
14
15void 13void
16init_dlink_nodes (void) 14init_dlink_nodes (void)
17{ 15{
16#if 0
18 node_heap = BlockHeapCreate (sizeof (node_t), HEAP_NODE); 17 node_heap = BlockHeapCreate (sizeof (node_t), HEAP_NODE);
19 18#endif
20 if (!node_heap)
21 {
22 slog (LG_INFO, "init_dlink_nodes(): block allocator failure.");
23 exit (EXIT_FAILURE);
24 }
25} 19}
26 20
27/* creates a new node */ 21/* creates a new node */
28node_t * 22node_t *
29node_create (void) 23node_create (void)
30{ 24{
31 node_t *n; 25 node_t *n;
32 26
33 /* allocate it */ 27 /* allocate it */
34 n = static_cast<node_t *> (BlockHeapAlloc (node_heap)); 28 n = new node_t;
35 29
36 /* initialize */ 30 /* initialize */
37 n->data = n->next = n->prev = NULL; 31 n->data = n->next = n->prev = NULL;
38 32
39 /* up the count */ 33 /* up the count */
40 claro_state.node++; 34 system_state.node++;
41 35
42 /* return a pointer to the new node */ 36 /* return a pointer to the new node */
43 return n; 37 return n;
44} 38}
45 39
48node_free (node_t *n) 42node_free (node_t *n)
49{ 43{
50 return_if_fail (n != NULL); 44 return_if_fail (n != NULL);
51 45
52 /* free it */ 46 /* free it */
53 BlockHeapFree (node_heap, n); 47 delete n;
54 48
55 /* down the count */ 49 /* down the count */
56 claro_state.node--; 50 system_state.node--;
57} 51}
58 52
59/* adds a node to the end of a list */ 53/* adds a node to the end of a list */
60void 54void
61node_add (void *data, node_t *n, list_t *l) 55node_add (void *data, node_t *n, list_t *l)
170{ 164{
171 node_t *n; 165 node_t *n;
172 166
173 return_val_if_fail (l != NULL, NULL); 167 return_val_if_fail (l != NULL, NULL);
174 168
175 LIST_FOREACH (n, l->head) if (n->data == data) 169 LIST_FOREACH (n, l->head)
170 if (n->data == data)
176 return n; 171 return n;
177 172
178 return NULL; 173 return NULL;
179} 174}
180 175
181void 176void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines