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

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

1/* 1/*
2 * uplink.C: Uplink management. 2 * uplink.C: Uplink management.
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: uplink.C,v 1.3 2007/07/21 13:23:22 pippijn Exp $"; 8static char const rcsid[] = "$Id: uplink.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $";
9 9
10#include "atheme.h" 10#include "atheme.h"
11#include "datastream.h" 11#include "datastream.h"
12#include "uplink.h" 12#include "uplink.h"
13 13
14list_t uplinks; 14list_t uplinks;
15uplink_t *curr_uplink; 15uplink_t *curr_uplink;
16 16
17static BlockHeap *uplink_heap;
18
19static void uplink_close (connection_t *cptr); 17static void uplink_close (connection_t *cptr);
20 18
21void 19void
22init_uplinks (void) 20init_uplinks (void)
23{ 21{
22#if 0
24 uplink_heap = BlockHeapCreate (sizeof (uplink_t), 4); 23 uplink_heap = BlockHeapCreate (sizeof (uplink_t), 4);
25 if (!uplink_heap) 24#endif
26 {
27 slog (LG_INFO, "init_uplinks(): block allocator failed.");
28 exit (EXIT_FAILURE);
29 }
30} 25}
31 26
32uplink_t * 27uplink_t *
33uplink_add (char *name, char *host, char *password, char *vhost, int port) 28uplink_add (char *name, char *host, char *password, char *vhost, int port)
34{ 29{
40 if ((u = uplink_find (name))) 35 if ((u = uplink_find (name)))
41 { 36 {
42 if (u->flags & UPF_ILLEGAL) 37 if (u->flags & UPF_ILLEGAL)
43 { 38 {
44 u->flags &= ~UPF_ILLEGAL; 39 u->flags &= ~UPF_ILLEGAL;
45 free (u->name); 40 sfree (u->name);
46 free (u->host); 41 sfree (u->host);
47 free (u->pass); 42 sfree (u->pass);
48 free (u->vhost); 43 sfree (u->vhost);
49 } 44 }
50 else 45 else
51 { 46 {
52 slog (LG_INFO, "Duplicate uplink %s.", name); 47 slog (LG_INFO, "Duplicate uplink %s.", name);
53 return NULL; 48 return NULL;
54 } 49 }
55 } 50 }
56 else 51 else
57 { 52 {
58 u = static_cast<uplink_t *> (BlockHeapAlloc (uplink_heap)); 53 u = new uplink_t;
59 n = node_create (); 54 n = node_create ();
60 u->node = n; 55 u->node = n;
61 node_add (u, n, &uplinks); 56 node_add (u, n, &uplinks);
62 cnt.uplink++; 57 cnt.uplink++;
63 } 58 }
77void 72void
78uplink_delete (uplink_t *u) 73uplink_delete (uplink_t *u)
79{ 74{
80 node_t *n = node_find (u, &uplinks); 75 node_t *n = node_find (u, &uplinks);
81 76
82 free (u->name); 77 sfree (u->name);
83 free (u->host); 78 sfree (u->host);
84 free (u->pass); 79 sfree (u->pass);
85 free (u->vhost); 80 sfree (u->vhost);
86 81
87 node_del (n, &uplinks); 82 node_del (n, &uplinks);
88 node_free (n); 83 node_free (n);
89 84
90 BlockHeapFree (uplink_heap, u); 85 delete u;
91 cnt.uplink--; 86 cnt.uplink--;
92} 87}
93 88
94uplink_t * 89uplink_t *
95uplink_find (char *name) 90uplink_find (char *name)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines