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
This commit is contained in:
parent
bffc6b36ae
commit
6beedf4c28
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user