Commit 0b485ec79869602c445e983ca6214e45c7ebffb4

Authored by Georg Hopp
1 parent dba76798

now its possible to say a hash that it should not free its members on cleanup...…

… useful if several structures hold the members
@@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
32 32
33 TR_CLASS(TR_Hash) { 33 TR_CLASS(TR_Hash) {
34 TR_Tree root; 34 TR_Tree root;
  35 + int cleanup_no_free;
35 }; 36 };
36 TR_INSTANCE_INIT(TR_Hash); 37 TR_INSTANCE_INIT(TR_Hash);
37 TR_CLASSVARS_DECL(TR_Hash) {}; 38 TR_CLASSVARS_DECL(TR_Hash) {};
@@ -35,7 +35,11 @@ tDelete(const void * node, const void * data, const int depth) @@ -35,7 +35,11 @@ tDelete(const void * node, const void * data, const int depth)
35 void 35 void
36 TR_hashCleanup(TR_Hash this) 36 TR_hashCleanup(TR_Hash this)
37 { 37 {
38 - TR_treeDestroy(&(this->root), tDelete); 38 + if (this->cleanup_no_free) {
  39 + TR_treeDestroy(&(this->root), NULL);
  40 + } else {
  41 + TR_treeDestroy(&(this->root), tDelete);
  42 + }
39 } 43 }
40 44
41 // vim: set ts=4 sw=4: 45 // vim: set ts=4 sw=4:
Please register or login to post a comment