diff options
| author | Greg Ercolano <erco@seriss.com> | 2014-01-14 01:08:40 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2014-01-14 01:08:40 +0000 |
| commit | 6beedf4c28f5b51ef6f2a035b113e6a7265612c3 (patch) | |
| tree | d5202a2c506381562f943ce421cc0fb49314aba9 | |
| parent | bffc6b36ae1dff9fb6e51399742fb4dc8e8f6539 (diff) | |
Fix small memleak in Fl_Tree::show_self() [used only for debugging anyway]
and convert from malloc/free -> new/delete
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10055 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_Tree_Item.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 127b531da..cd40bfdd9 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -151,23 +151,23 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) { /// Used mainly for debugging. /// void Fl_Tree_Item::show_self(const char *indent) const { - if ( label() ) { + const char *thelabel = label() ? label() : "(NULL)"; #if FLTK_ABI_VERSION >= 10301 - printf("%s-%s (%d children, this=%p, parent=%p, prev=%p, next=%p, depth=%d)\n", - indent,label(),children(),(void*)this, (void*)_parent, - _prev_sibling, _next_sibling, depth()); + printf("%s-%s (%d children, this=%p, parent=%p, prev=%p, next=%p, depth=%d)\n", + indent,thelabel,children(),(void*)this, (void*)_parent, + _prev_sibling, _next_sibling, depth()); #else /*FLTK_ABI_VERSION*/ - printf("%s-%s (%d children, this=%p, parent=%p depth=%d)\n", - indent,label(),children(),(void*)this, (void*)_parent, depth()); + printf("%s-%s (%d children, this=%p, parent=%p depth=%d)\n", + indent,thelabel,children(),(void*)this, (void*)_parent, depth()); #endif /*FLTK_ABI_VERSION*/ - } if ( children() ) { - char *i2 = (char*)malloc(strlen(indent) + 2); + char *i2 = new char [strlen(indent)+2]; strcpy(i2, indent); strcat(i2, " |"); for ( int t=0; t<children(); t++ ) { child(t)->show_self(i2); } + delete[] i2; } fflush(stdout); } |
