diff options
author | Tom Tromey <tromey@adacore.com> | 2023-04-06 09:05:58 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-04-06 10:01:10 -0600 |
commit | 55af06a70e769f4dae10d919f9ea10a802a4aac7 (patch) | |
tree | f87f2cd16480f7b402139e864a0fafaf22b926ef /gdb/python | |
parent | b4f767131f75179df4f47fc40e177f2607fb1003 (diff) | |
download | gdb-55af06a70e769f4dae10d919f9ea10a802a4aac7.zip gdb-55af06a70e769f4dae10d919f9ea10a802a4aac7.tar.gz gdb-55af06a70e769f4dae10d919f9ea10a802a4aac7.tar.bz2 |
Use unique_xmalloc_ptr in apply_ext_lang_type_printers
This changes apply_ext_lang_type_printers to use unique_xmalloc_ptr,
removing some manual memory management. Regression tested on x86-64
Fedora 36.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/python.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c index b295ff8..ea51766 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -112,7 +112,8 @@ static void gdbpy_start_type_printers (const struct extension_language_defn *, struct ext_lang_type_printers *); static enum ext_lang_rc gdbpy_apply_type_printers (const struct extension_language_defn *, - const struct ext_lang_type_printers *, struct type *, char **); + const struct ext_lang_type_printers *, struct type *, + gdb::unique_xmalloc_ptr<char> *); static void gdbpy_free_type_printers (const struct extension_language_defn *, struct ext_lang_type_printers *); static void gdbpy_set_quit_flag (const struct extension_language_defn *); @@ -1700,7 +1701,7 @@ gdbpy_start_type_printers (const struct extension_language_defn *extlang, /* If TYPE is recognized by some type printer, store in *PRETTIED_TYPE a newly allocated string holding the type's replacement name, and return - EXT_LANG_RC_OK. The caller is responsible for freeing the string. + EXT_LANG_RC_OK. If there's a Python error return EXT_LANG_RC_ERROR. Otherwise, return EXT_LANG_RC_NOP. This is the extension_language_ops.apply_type_printers "method". */ @@ -1708,7 +1709,8 @@ gdbpy_start_type_printers (const struct extension_language_defn *extlang, static enum ext_lang_rc gdbpy_apply_type_printers (const struct extension_language_defn *extlang, const struct ext_lang_type_printers *ext_printers, - struct type *type, char **prettied_type) + struct type *type, + gdb::unique_xmalloc_ptr<char> *prettied_type) { PyObject *printers_obj = (PyObject *) ext_printers->py_type_printers; gdb::unique_xmalloc_ptr<char> result; @@ -1763,7 +1765,7 @@ gdbpy_apply_type_printers (const struct extension_language_defn *extlang, return EXT_LANG_RC_ERROR; } - *prettied_type = result.release (); + *prettied_type = std::move (result); return EXT_LANG_RC_OK; } |