diff options
author | Tom Tromey <tom@tromey.com> | 2016-11-06 21:10:18 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-01-10 19:13:31 -0700 |
commit | d1b3de2e43380a0c51772a40315cd2268573d985 (patch) | |
tree | f8520309f7e341baca818d1b0b663779d6122589 /gdb/python/py-cmd.c | |
parent | 3bb4338431288002c2225ff660e1500818684c16 (diff) | |
download | gdb-d1b3de2e43380a0c51772a40315cd2268573d985.zip gdb-d1b3de2e43380a0c51772a40315cd2268573d985.tar.gz gdb-d1b3de2e43380a0c51772a40315cd2268573d985.tar.bz2 |
Use gdbpy_ref in gdbpy_string_to_argv
This chanes gdbpy_string_to_argv to use gdbpy_ref.
2017-01-10 Tom Tromey <tom@tromey.com>
* python/py-cmd.c (gdbpy_string_to_argv): Use gdbpy_ref.
Diffstat (limited to 'gdb/python/py-cmd.c')
-rw-r--r-- | gdb/python/py-cmd.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index 130466d..e2879b7 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -27,6 +27,7 @@ #include "cli/cli-decode.h" #include "completer.h" #include "language.h" +#include "py-ref.h" /* Struct representing built-in completion types. */ struct cmdpy_completer @@ -784,13 +785,12 @@ PyTypeObject cmdpy_object_type = PyObject * gdbpy_string_to_argv (PyObject *self, PyObject *args) { - PyObject *py_argv; const char *input; if (!PyArg_ParseTuple (args, "s", &input)) return NULL; - py_argv = PyList_New (0); + gdbpy_ref py_argv (PyList_New (0)); if (py_argv == NULL) return NULL; @@ -805,21 +805,18 @@ gdbpy_string_to_argv (PyObject *self, PyObject *args) for (i = 0; c_argv[i] != NULL; ++i) { - PyObject *argp = PyString_FromString (c_argv[i]); + gdbpy_ref argp (PyString_FromString (c_argv[i])); if (argp == NULL - || PyList_Append (py_argv, argp) < 0) + || PyList_Append (py_argv.get (), argp.get ()) < 0) { - Py_XDECREF (argp); - Py_DECREF (py_argv); freeargv (c_argv); return NULL; } - Py_DECREF (argp); } freeargv (c_argv); } - return py_argv; + return py_argv.release (); } |