Debian Codegraph @

examples/cxx/excxx_repquote/RepConfigInfo.cpp

raw
1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2001, 2013 Oracle and/or its affiliates. All rights reserved.
5 *
6 * $Id$
7 */
8
9 #include <cstdlib>
10 #include <cstring>
11
12 #include "RepConfigInfo.h"
13
14 RepConfigInfo::RepConfigInfo()
15 {
16 start_policy = DB_REP_ELECTION;
17 home = NULL;
18 got_listen_address = false;
19 nrsites = 0;
20 priority = 100;
21 verbose = false;
22 this_host.creator = false;
23 other_hosts = NULL;
24 ack_policy = DB_REPMGR_ACKS_QUORUM;
25 bulk = false;
26 }
27
28 RepConfigInfo::~RepConfigInfo()
29 {
30 // release any other_hosts structs.
31 if (other_hosts != NULL) {
32 REP_HOST_INFO *CurItem = other_hosts;
33 while (CurItem->next != NULL) {
34 REP_HOST_INFO *TmpItem = CurItem->next;
35 free(CurItem);
36 CurItem = TmpItem;
37 }
38 free(CurItem);
39 }
40 other_hosts = NULL;
41 }
42
43 void RepConfigInfo::addOtherHost(char* host, int port, bool peer)
44 {
45 REP_HOST_INFO *newinfo;
46 newinfo = (REP_HOST_INFO*)malloc(sizeof(REP_HOST_INFO));
47 newinfo->host = host;
48 newinfo->port = port;
49 newinfo->peer = peer;
50 if (other_hosts == NULL) {
51 other_hosts = newinfo;
52 newinfo->next = NULL;
53 } else {
54 newinfo->next = other_hosts;
55 other_hosts = newinfo;
56 }
57 nrsites++;
58 }