OSDN Git Service

2002-05-15 Martin M. Hunt <hunt@redhat.com>
authorMartin Hunt <hunt@redhat.com>
Thu, 16 May 2002 01:08:51 +0000 (01:08 +0000)
committerMartin Hunt <hunt@redhat.com>
Thu, 16 May 2002 01:08:51 +0000 (01:08 +0000)
* generic/gdbtk-cmds.c (gdb_eval): For mem_file stuff, delete
the file when done and free memory.

gdb/gdbtk/generic/gdbtk-cmds.c

index ae15532..10629af 100644 (file)
@@ -622,6 +622,7 @@ gdb_eval (ClientData clientData, Tcl_Interp *interp,
   value_ptr val;
   struct ui_file *stb;
   long dummy;
+  char *result;
 
   if (objc != 2 && objc != 3)
     {
@@ -638,10 +639,13 @@ gdb_eval (ClientData clientData, Tcl_Interp *interp,
 
   /* "Print" the result of the expression evaluation. */
   stb = mem_fileopen ();
+  make_cleanup_ui_file_delete (stb);
   val_print (VALUE_TYPE (val), VALUE_CONTENTS (val),
             VALUE_EMBEDDED_OFFSET (val), VALUE_ADDRESS (val),
             stb, format, 0, 0, 0);
-  Tcl_SetObjResult (interp, Tcl_NewStringObj (ui_file_xstrdup (stb, &dummy), -1));
+  result = ui_file_xstrdup (stb, &dummy);
+  Tcl_SetObjResult (interp, Tcl_NewStringObj (result, -1));
+  xfree (result);
   result_ptr->flags |= GDBTK_IN_TCL_RESULT;
 
   do_cleanups (old_chain);