mail[Wesnoth-commits] r25237 - /trunk/src/server/simple_wml.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by dave on March 28, 2008 - 14:44:
Author: dave
Date: Fri Mar 28 14:44:02 2008
New Revision: 25237

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25237&view=rev
Log:
debugging code for simple_wml

Modified:
    trunk/src/server/simple_wml.cpp

Modified: trunk/src/server/simple_wml.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/simple_wml.cpp?rev=25237&r1=25236&r2=25237&view=diff
==============================================================================
--- trunk/src/server/simple_wml.cpp (original)
+++ trunk/src/server/simple_wml.cpp Fri Mar 28 14:44:02 2008
@@ -14,6 +14,13 @@
 namespace simple_wml {
 
 namespace {
+
+void debug_delete(node* n) {
+       if(n) {
+               delete n;
+               memset(n, 0xab, sizeof(*n));
+       }
+}
 
 char* uncompress_buffer(const string_span& input, string_span* span)
 {
@@ -120,7 +127,9 @@
 
 node::node(document& doc, node* parent)
   : doc_(&doc), parent_(parent)
-{}
+{
+       fprintf(stderr, "c 0x%llx\n", (uint64_t)this);
+}
 
 node::node(document& doc, node* parent, const char** str, int depth)
   : doc_(&doc), parent_(parent)
@@ -235,18 +244,17 @@
        }
 
        output_cache_ = string_span(begin, s - begin);
+       fprintf(stderr, "p 0x%llx\n", (uint64_t)this);
 }
 
 node::~node()
 {
+       fprintf(stderr, "d 0x%llx\n", (uint64_t)this);
        for(child_map::iterator i = children_.begin(); i != children_.end(); 
++i) {
                for(child_list::iterator j = i->second.begin(); j != 
i->second.end(); ++j) {
-                       delete *j;
+                       debug_delete(*j);
                }       
        }
-
-       //TODO: DEBUG CODE. Fill with a memory pattern to debug crashing!
-       memset(this, 0xab, sizeof(*this));
 }
 
 namespace {
@@ -360,7 +368,7 @@
                return;
        }
 
-       delete list[index];
+       debug_delete(list[index]);
        list.erase(list.begin() + index);
 }
 
@@ -690,12 +698,9 @@
        }
 
        buffers_.clear();
-       delete root_;
+       debug_delete(root_);
 
        detach_list();
-
-       //TODO: DEBUG CODE. Fill with a memory pattern to debug crashing!
-       memset(this, 0xab, sizeof(*this));
 }
 
 const char* document::dup_string(const char* str)
@@ -761,7 +766,7 @@
 void document::compress()
 {
        output_compressed();
-       delete root_;
+       debug_delete(root_);
        root_ = NULL;
        output_ = NULL;
        std::vector<char*> new_buffers;
@@ -812,7 +817,7 @@
 {
        compressed_buf_ = string_span();
        output_ = NULL;
-       delete root_;
+       debug_delete(root_);
        root_ = new node(*this, NULL);
        for(std::vector<char*>::iterator i = buffers_.begin(); i != 
buffers_.end(); ++i) {
                delete [] *i;




Related Messages


Powered by MHonArc, Updated Fri Mar 28 15:02:47 2008