]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * tools.c: Various functions needed here and there. | |
4 | * | |
5 | * Copyright (C) 1996-2002 Hybrid Development Team | |
6 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
21 | * USA | |
22 | * | |
23 | * $Id: tools.c 3201 2007-02-04 01:59:38Z jilles $ | |
24 | * | |
25 | * Here is the original header: | |
26 | * | |
27 | * Useful stuff, ripped from places .. | |
28 | * adrian chadd <adrian@creative.net.au> | |
29 | * | |
30 | * When you update these functions make sure you update the ones in tools.h | |
31 | * as well!!! | |
32 | */ | |
33 | ||
34 | #include "stdinc.h" | |
35 | #define TOOLS_C | |
36 | #include "tools.h" | |
37 | #include "balloc.h" | |
38 | #include "s_user.h" | |
39 | ||
40 | #ifndef NDEBUG | |
41 | /* | |
42 | * frob some memory. debugging time. | |
43 | * -- adrian | |
44 | */ | |
45 | void | |
46 | mem_frob(void *data, int len) | |
47 | { | |
48 | unsigned long x = 0xdeadbeef; | |
49 | unsigned char *b = (unsigned char *)&x; | |
50 | int i; | |
51 | char *cdata = data; | |
52 | for (i = 0; i < len; i++) | |
53 | { | |
54 | *cdata = b[i % 4]; | |
55 | cdata++; | |
56 | } | |
57 | } | |
58 | #endif | |
59 | ||
60 | /* | |
61 | * init_dlink_nodes | |
62 | * | |
63 | */ | |
64 | extern BlockHeap *dnode_heap; | |
65 | void | |
66 | init_dlink_nodes(void) | |
67 | { | |
68 | dnode_heap = BlockHeapCreate(sizeof(dlink_node), DNODE_HEAP_SIZE); | |
69 | if(dnode_heap == NULL) | |
70 | outofmemory(); | |
71 | } | |
72 | ||
73 | /* | |
74 | * make_dlink_node | |
75 | * | |
76 | * inputs - NONE | |
77 | * output - pointer to new dlink_node | |
78 | * side effects - NONE | |
79 | */ | |
80 | dlink_node * | |
81 | make_dlink_node(void) | |
82 | { | |
83 | return(BlockHeapAlloc(dnode_heap)); | |
84 | } | |
85 | ||
86 | /* | |
87 | * free_dlink_node | |
88 | * | |
89 | * inputs - pointer to dlink_node | |
90 | * output - NONE | |
91 | * side effects - free given dlink_node | |
92 | */ | |
93 | void | |
94 | free_dlink_node(dlink_node * ptr) | |
95 | { | |
96 | assert(ptr != NULL); | |
97 | ||
98 | BlockHeapFree(dnode_heap, ptr); | |
99 | } |