]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid manual resource management in py-framefilter.c
authorTom Tromey <tom@tromey.com>
Sun, 23 Apr 2017 17:23:43 +0000 (11:23 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 27 Mar 2018 03:57:11 +0000 (21:57 -0600)
This patch removes the last bit of manual resource management from
py-framefilter.c.  This will be useful in the next patch.

gdb/ChangeLog
2018-03-26  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (enumerate_args): Use
gdb::unique_xmalloc_ptr.

gdb/ChangeLog
gdb/python/py-framefilter.c

index ed5d5bedcb194ce505a4c3fa2a50d659558863b1..5cc8d9ef9c5da6f05fbdff4d8bcf01c467532602 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-26  Tom Tromey  <tom@tromey.com>
+
+       * python/py-framefilter.c (enumerate_args): Use
+       gdb::unique_xmalloc_ptr.
+
 2018-03-26  Tom Tromey  <tom@tromey.com>
 
        * python/py-framefilter.c (py_print_frame): Return
index 1dc15ae14e4f7f709065718514e0a9f3efb6a7bb..dcac42df8ece65cabbf84f344f137bae44e27f18 100644 (file)
@@ -560,6 +560,9 @@ enumerate_args (PyObject *iter,
            }
          END_CATCH
 
+         gdb::unique_xmalloc_ptr<char> arg_holder (arg.error);
+         gdb::unique_xmalloc_ptr<char> entry_holder (entryarg.error);
+
          /* The object has not provided a value, so this is a frame
             argument to be read by GDB.  In this case we have to
             account for entry-values.  */
@@ -571,11 +574,7 @@ enumerate_args (PyObject *iter,
                                       args_type,
                                       print_args_field,
                                       NULL) == EXT_LANG_BT_ERROR)
-               {
-                 xfree (arg.error);
-                 xfree (entryarg.error);
-                 return EXT_LANG_BT_ERROR;
-               }
+               return EXT_LANG_BT_ERROR;
            }
 
          if (entryarg.entry_kind != print_entry_values_no)
@@ -589,8 +588,6 @@ enumerate_args (PyObject *iter,
                    }
                  CATCH (except, RETURN_MASK_ALL)
                    {
-                     xfree (arg.error);
-                     xfree (entryarg.error);
                      gdbpy_convert_exception (except);
                      return EXT_LANG_BT_ERROR;
                    }
@@ -600,15 +597,8 @@ enumerate_args (PyObject *iter,
              if (py_print_single_arg (out, NULL, &entryarg, NULL, &opts,
                                       args_type, print_args_field, NULL)
                  == EXT_LANG_BT_ERROR)
-               {
-                 xfree (arg.error);
-                 xfree (entryarg.error);
-                 return EXT_LANG_BT_ERROR;
-               }
+               return EXT_LANG_BT_ERROR;
            }
-
-         xfree (arg.error);
-         xfree (entryarg.error);
        }
       else
        {