* [patch] gdbtk-varobj.c cleanup and minor fix
@ 2002-11-06 12:33 Martin M. Hunt
0 siblings, 0 replies; only message in thread
From: Martin M. Hunt @ 2002-11-06 12:33 UTC (permalink / raw)
To: insight
[-- Attachment #1: Type: text/plain, Size: 283 bytes --]
When updating a variable, if there is an error, it needs to be returned.
2002-11-06 Martin M. Hunt <hunt@redhat.com>
* generic/gdbtk-varobj.c: Remove FREEIF and replace with xfree.
Make format_string static.
(variable_update): Return an object
with "-1" in it on error.
[-- Attachment #2: p --]
[-- Type: text/x-patch, Size: 5858 bytes --]
Index: gdbtk-varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-varobj.c,v
retrieving revision 1.14
diff -p -r1.14 gdbtk-varobj.c
*** gdbtk-varobj.c 3 Aug 2002 16:22:07 -0000 1.14
--- gdbtk-varobj.c 6 Nov 2002 20:28:14 -0000
*************** static void install_variable (Tcl_Interp
*** 70,82 ****
static void uninstall_variable (Tcl_Interp *, char *);
/* String representations of gdb's format codes */
! char *format_string[] =
{"natural", "binary", "decimal", "hexadecimal", "octal"};
\f
- #if defined(FREEIF)
- #undef FREEIF
- #endif
- #define FREEIF(x) if (x != NULL) free((char *) (x))
/* Initialize the variable code. This function should be called once
to install and initialize the variable code into the interpreter. */
--- 70,78 ----
static void uninstall_variable (Tcl_Interp *, char *);
/* String representations of gdb's format codes */
! static char *format_string[] =
{"natural", "binary", "decimal", "hexadecimal", "octal"};
\f
/* Initialize the variable code. This function should be called once
to install and initialize the variable code into the interpreter. */
*************** variable_obj_command (ClientData clientD
*** 259,271 ****
{
char *name = varobj_get_expression (var);
Tcl_SetObjResult (interp, Tcl_NewStringObj (name, -1));
! FREEIF (name);
}
break;
case VARIABLE_EDITABLE:
! Tcl_SetObjResult (interp, Tcl_NewIntObj (
! varobj_get_attributes (var) & 0x00000001 /* Editable? */ ));
break;
case VARIABLE_UPDATE:
--- 255,267 ----
{
char *name = varobj_get_expression (var);
Tcl_SetObjResult (interp, Tcl_NewStringObj (name, -1));
! xfree (name);
}
break;
case VARIABLE_EDITABLE:
! Tcl_SetObjResult (interp,
! Tcl_NewIntObj (varobj_get_attributes (var) & 0x00000001 /* Editable? */ ));
break;
case VARIABLE_UPDATE:
*************** variable_create (Tcl_Interp *interp, int
*** 337,343 ****
if (Tcl_GetIndexFromObj (interp, objv[0], create_options, "options",
0, &index) != TCL_OK)
{
! free (obj_name);
result_ptr->flags |= GDBTK_IN_TCL_RESULT;
return TCL_ERROR;
}
--- 333,339 ----
if (Tcl_GetIndexFromObj (interp, objv[0], create_options, "options",
0, &index) != TCL_OK)
{
! xfree (obj_name);
result_ptr->flags |= GDBTK_IN_TCL_RESULT;
return TCL_ERROR;
}
*************** variable_create (Tcl_Interp *interp, int
*** 380,390 ****
Tcl_SetObjResult (interp, Tcl_NewStringObj (obj_name, -1));
result_ptr->flags |= GDBTK_IN_TCL_RESULT;
! free (obj_name);
return TCL_OK;
}
! free (obj_name);
return TCL_ERROR;
}
--- 376,386 ----
Tcl_SetObjResult (interp, Tcl_NewStringObj (obj_name, -1));
result_ptr->flags |= GDBTK_IN_TCL_RESULT;
! xfree (obj_name);
return TCL_OK;
}
! xfree (obj_name);
return TCL_ERROR;
}
*************** variable_delete (Tcl_Interp *interp, str
*** 403,413 ****
while (*vc != NULL)
{
uninstall_variable (interp, *vc);
! free (*vc);
vc++;
}
! FREEIF (dellist);
}
/* Return a list of all the children of VAR, creating them if necessary. */
--- 399,409 ----
while (*vc != NULL)
{
uninstall_variable (interp, *vc);
! xfree (*vc);
vc++;
}
! xfree (dellist);
}
/* Return a list of all the children of VAR, creating them if necessary. */
*************** variable_children (Tcl_Interp *interp, s
*** 434,440 ****
vc++;
}
! FREEIF (childlist);
return list;
}
--- 430,436 ----
vc++;
}
! xfree (childlist);
return list;
}
*************** variable_update (Tcl_Interp *interp, str
*** 448,460 ****
struct varobj **changelist;
struct varobj **vc;
- changed = Tcl_NewListObj (0, NULL);
-
/* varobj_update() can return -1 if the variable is no longer around,
i.e. we stepped out of the frame in which a local existed. */
if (varobj_update (var, &changelist) == -1)
! return changed;
vc = changelist;
while (*vc != NULL)
{
--- 444,455 ----
struct varobj **changelist;
struct varobj **vc;
/* varobj_update() can return -1 if the variable is no longer around,
i.e. we stepped out of the frame in which a local existed. */
if (varobj_update (var, &changelist) == -1)
! return Tcl_NewStringObj ("-1", -1);
+ changed = Tcl_NewListObj (0, NULL);
vc = changelist;
while (*vc != NULL)
{
*************** variable_update (Tcl_Interp *interp, str
*** 464,470 ****
vc++;
}
! FREEIF (changelist);
return changed;
}
--- 459,465 ----
vc++;
}
! xfree (changelist);
return changed;
}
*************** variable_type (Tcl_Interp *interp, int o
*** 545,551 ****
}
Tcl_SetObjResult (interp, Tcl_NewStringObj (string, -1));
! FREEIF (string);
return TCL_OK;
}
--- 540,546 ----
}
Tcl_SetObjResult (interp, Tcl_NewStringObj (string, -1));
! xfree (string);
return TCL_OK;
}
*************** variable_value (Tcl_Interp *interp, int
*** 593,599 ****
else
{
Tcl_SetObjResult (interp, Tcl_NewStringObj (r, -1));
! FREEIF (r);
return TCL_OK;
}
}
--- 588,594 ----
else
{
Tcl_SetObjResult (interp, Tcl_NewStringObj (r, -1));
! xfree (r);
return TCL_OK;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-06 20:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-06 12:33 [patch] gdbtk-varobj.c cleanup and minor fix Martin M. Hunt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).