From: Anders R. <ma...@us...> - 2006-01-29 21:06:11
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17778/src/common/util Modified Files: prb.cpp Log Message: - Created freeing of msgfactories at exit - Created copy of quest prerequistes. This to prevent dublicate free on prerequisite operations at exit (valgrind complained about that). - Fixed some leaks in dictionary where equal entities added to binaryRBtrees wasn't deleted. Added an dublicate entry case the Insert function to return a pointer to the existing entity. Index: prb.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/prb.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** prb.cpp 17 Jun 2005 13:51:38 -0000 1.3 --- prb.cpp 29 Jan 2006 21:05:54 -0000 1.4 *************** *** 802,803 **** --- 802,851 ---- #endif #endif + + + #ifdef TESTBINARYRBTREE + #ifndef PRB_H + #include "prb.h" + + class TestBinaryRBTreeElement + { + public: + int id; + TestBinaryRBTreeElement(int num) + { + id = num; + }; + + ~TestBinaryRBTreeElement() + { + printf("Free node %d\n",id); + }; + + bool operator==(TestBinaryRBTreeElement& other) const + { + return id==other.id; + }; + + bool operator<(TestBinaryRBTreeElement& other) const + { + return id<other.id; + }; + + }; + + + + int main() + { + BinaryRBTree<TestBinaryRBTreeElement> tree; + + tree.Insert(new TestBinaryRBTreeElement(3), true); + tree.Insert(new TestBinaryRBTreeElement(2), true); + tree.Insert(new TestBinaryRBTreeElement(1), true); + tree.Insert(new TestBinaryRBTreeElement(4), true); + tree.Insert(new TestBinaryRBTreeElement(5), true); + } + // End of test + #endif + #endif + |