From 6beedf4c28f5b51ef6f2a035b113e6a7265612c3 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Tue, 14 Jan 2014 01:08:40 +0000 Subject: 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 --- src/Fl_Tree_Item.cxx | 16 ++++++++-------- 1 file 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; tshow_self(i2); } + delete[] i2; } fflush(stdout); } -- cgit v1.2.3