From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14711 invoked by alias); 6 Nov 2002 20:33:20 -0000 Mailing-List: contact insight-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sources.redhat.com Received: (qmail 14692 invoked from network); 6 Nov 2002 20:33:19 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 6 Nov 2002 20:33:19 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id gA6KAgw20131 for ; Wed, 6 Nov 2002 15:10:42 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gA6KXIf14302 for ; Wed, 6 Nov 2002 15:33:18 -0500 Received: from DRAGON (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gA6KXHT15139 for ; Wed, 6 Nov 2002 15:33:17 -0500 Subject: [patch] gdbtk-varobj.c cleanup and minor fix From: "Martin M. Hunt" To: insight@sources.redhat.com Content-Type: multipart/mixed; boundary="=-QjULKHz1EqBxYxN1aOnr" Date: Wed, 06 Nov 2002 12:33:00 -0000 Message-Id: <1036614852.1127.11.camel@localhost.localdomain> Mime-Version: 1.0 X-SW-Source: 2002-q4/txt/msg00081.txt.bz2 --=-QjULKHz1EqBxYxN1aOnr Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 283 When updating a variable, if there is an error, it needs to be returned. 2002-11-06 Martin M. Hunt * 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. --=-QjULKHz1EqBxYxN1aOnr Content-Disposition: attachment; filename=p Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; name=p; charset=UTF-8 Content-length: 5974 Index: gdbtk-varobj.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 *); =20=20 /* String representations of gdb's format codes */ ! char *format_string[] =3D {"natural", "binary", "decimal", "hexadecimal", "octal"}; =0C - #if defined(FREEIF) - #undef FREEIF - #endif - #define FREEIF(x) if (x !=3D NULL) free((char *) (x)) =20=20 /* 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 *); =20=20 /* String representations of gdb's format codes */ ! static char *format_string[] =3D {"natural", "binary", "decimal", "hexadecimal", "octal"}; =0C =20=20 /* 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 =3D varobj_get_expression (var); Tcl_SetObjResult (interp, Tcl_NewStringObj (name, -1)); ! FREEIF (name); } break; =20=20 case VARIABLE_EDITABLE: ! Tcl_SetObjResult (interp, Tcl_NewIntObj ( ! varobj_get_attributes (var) & 0x00000001 /* Editable? */ )); break; =20=20 case VARIABLE_UPDATE: --- 255,267 ---- { char *name =3D varobj_get_expression (var); Tcl_SetObjResult (interp, Tcl_NewStringObj (name, -1)); ! xfree (name); } break; =20=20 case VARIABLE_EDITABLE: ! Tcl_SetObjResult (interp,=20 ! Tcl_NewIntObj (varobj_get_attributes (var) & 0x00000001 /* Editable? *= / )); break; =20=20 case VARIABLE_UPDATE: *************** variable_create (Tcl_Interp *interp, int *** 337,343 **** if (Tcl_GetIndexFromObj (interp, objv[0], create_options, "options", 0, &index) !=3D TCL_OK) { ! free (obj_name); result_ptr->flags |=3D GDBTK_IN_TCL_RESULT; return TCL_ERROR; } --- 333,339 ---- if (Tcl_GetIndexFromObj (interp, objv[0], create_options, "options", 0, &index) !=3D TCL_OK) { ! xfree (obj_name); result_ptr->flags |=3D 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 |=3D GDBTK_IN_TCL_RESULT; =20=20 ! free (obj_name); return TCL_OK; } =20=20 ! free (obj_name); return TCL_ERROR; } =20=20 --- 376,386 ---- Tcl_SetObjResult (interp, Tcl_NewStringObj (obj_name, -1)); result_ptr->flags |=3D GDBTK_IN_TCL_RESULT; =20=20 ! xfree (obj_name); return TCL_OK; } =20=20 ! xfree (obj_name); return TCL_ERROR; } =20=20 *************** variable_delete (Tcl_Interp *interp, str *** 403,413 **** while (*vc !=3D NULL) { uninstall_variable (interp, *vc); ! free (*vc); vc++; } =20=20 ! FREEIF (dellist); } =20=20 /* Return a list of all the children of VAR, creating them if necessary. = */ --- 399,409 ---- while (*vc !=3D NULL) { uninstall_variable (interp, *vc); ! xfree (*vc); vc++; } =20=20 ! xfree (dellist); } =20=20 /* Return a list of all the children of VAR, creating them if necessary. = */ *************** variable_children (Tcl_Interp *interp, s *** 434,440 **** vc++; } =20=20 ! FREEIF (childlist); return list; } =20=20 --- 430,436 ---- vc++; } =20=20 ! xfree (childlist); return list; } =20=20 *************** variable_update (Tcl_Interp *interp, str *** 448,460 **** struct varobj **changelist; struct varobj **vc; =20=20 - changed =3D Tcl_NewListObj (0, NULL); -=20 /* 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) =3D=3D -1) ! return changed; =20=20 vc =3D changelist; while (*vc !=3D NULL) { --- 444,455 ---- struct varobj **changelist; struct varobj **vc; =20=20 /* 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) =3D=3D -1) ! return Tcl_NewStringObj ("-1", -1); =20=20 + changed =3D Tcl_NewListObj (0, NULL);=20=20 vc =3D changelist; while (*vc !=3D NULL) { *************** variable_update (Tcl_Interp *interp, str *** 464,470 **** vc++; } =20=20 ! FREEIF (changelist); return changed; } =20=20 --- 459,465 ---- vc++; } =20=20 ! xfree (changelist); return changed; } =20=20 *************** variable_type (Tcl_Interp *interp, int o *** 545,551 **** } =20=20 Tcl_SetObjResult (interp, Tcl_NewStringObj (string, -1)); ! FREEIF (string); return TCL_OK; } =20=20 --- 540,546 ---- } =20=20 Tcl_SetObjResult (interp, Tcl_NewStringObj (string, -1)); ! xfree (string); return TCL_OK; } =20=20 *************** variable_value (Tcl_Interp *interp, int=20 *** 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; } } --=-QjULKHz1EqBxYxN1aOnr--