Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [pushed 2/2] gdb: make gdb_cplus_demangle_print return gdb::unique_xmalloc_ptr
Date: Wed, 14 Oct 2026 15:46:02 -0400	[thread overview]
Message-ID: <20261014194606.523510-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20261014194606.523510-1-simon.marchi@efficios.com>

Change gdb_cplus_demangle_print to return a
gdb::unique_xmalloc_ptr<char> instead of a raw pointer.

Change-Id: I116c0e53f504b926848afa9b398c2ddf88dbe0b4
---
 gdb/cp-name-parser.c | 5 ++---
 gdb/cp-support.c     | 7 ++++---
 gdb/cp-support.h     | 7 +++----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/gdb/cp-name-parser.c b/gdb/cp-name-parser.c
index 80779fbc6062..fe2ffd61a6c8 100644
--- a/gdb/cp-name-parser.c
+++ b/gdb/cp-name-parser.c
@@ -382,9 +382,8 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
 {
   size_t err;
 
-  char *res = gdb_cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI,
-					result, estimated_len, &err);
-  return gdb::unique_xmalloc_ptr<char> (res);
+  return gdb_cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, result,
+				   estimated_len, &err);
 }
 
 /* Merge the two parse trees given by DEST and SRC.  The parse tree
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index c386f7fea271..3881d4b4cdeb 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1678,14 +1678,15 @@ gdb_demangle (const char *name, int options)
 
 /* See cp-support.h.  */
 
-char *
+gdb::unique_xmalloc_ptr<char>
 gdb_cplus_demangle_print (int options,
 			  struct demangle_component *tree,
 			  int estimated_length,
 			  size_t *p_allocated_size)
 {
-  return cplus_demangle_print (options | DMGL_VERBOSE, tree,
-			       estimated_length, p_allocated_size);
+  return gdb::unique_xmalloc_ptr<char>
+    (cplus_demangle_print (options | DMGL_VERBOSE, tree,
+			   estimated_length, p_allocated_size));
 }
 
 /* A wrapper for cplus_demangle_v3_components that forces
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 87eee25a5798..2263d5b725c0 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -202,10 +202,9 @@ gdb::unique_xmalloc_ptr<char> gdb_demangle (const char *name, int options);
 
 /* A wrapper for cplus_demangle_print.  */
 
-extern char *gdb_cplus_demangle_print (int options,
-				       struct demangle_component *tree,
-				       int estimated_length,
-				       size_t *p_allocated_size);
+extern gdb::unique_xmalloc_ptr<char> gdb_cplus_demangle_print
+  (int options, struct demangle_component *tree, int estimated_length,
+   size_t *p_allocated_size);
 
 /* Find an instance of the character C in the string S that is outside
    of all parenthesis pairs, single-quoted strings, and double-quoted
-- 
2.56.0


      reply	other threads:[~2026-10-14 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 19:46 [pushed 1/2] gdb: make class_name_from_physname " Simon Marchi
2026-10-14 19:46 ` Simon Marchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261014194606.523510-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox