Titan Core Initial Contribution
[deliverable/titan.core.git] / langviz / Node.cc
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #include "Node.hh"
9 #include "error.h"
10 #include <stdio.h>
11
12 // =================================
13 // ===== Node
14 // =================================
15
16 int Node::counter=0;
17 #ifdef MEMORY_DEBUG
18 static Node *list_head = 0, *list_tail = 0;
19 #endif
20
21 Node::Node()
22 {
23 #ifdef MEMORY_DEBUG
24 prev_node = list_tail;
25 next_node = 0;
26 if (list_tail) list_tail->next_node = this;
27 else list_head = this;
28 list_tail = this;
29 #endif
30 counter++;
31 }
32
33 Node::Node(const Node& p)
34 {
35 #ifdef MEMORY_DEBUG
36 prev_node = list_tail;
37 next_node = 0;
38 if (list_tail) list_tail->next_node = this;
39 else list_head = this;
40 list_tail = this;
41 #endif
42 counter++;
43 }
44
45 Node::~Node()
46 {
47 counter--;
48 #ifdef MEMORY_DEBUG
49 if (prev_node) prev_node->next_node = next_node;
50 else list_head = next_node;
51 if (next_node) next_node->prev_node = prev_node;
52 else list_tail = prev_node;
53 #endif
54 }
55
56 void Node::chk_counter()
57 {
58 DEBUG(1, "Node::counter is %d", counter);
59 if(counter)
60 WARNING("%d nodes were not deleted."
61 " Please send a bug report including"
62 " the current input file(s).", counter);
63 #ifdef MEMORY_DEBUG
64 for(Node *iter = list_head; iter; iter = iter->next_node) {
65 fprintf(stderr, "Undeleted node address: %p.\n", iter);
66 }
67 list_head = 0;
68 list_tail = 0;
69 #endif
70 }
71
This page took 0.039359 seconds and 5 git commands to generate.