public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove make_hex_string
@ 2019-09-25 15:54 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-09-25 15:54 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=858f25f0dd3c7013e4c87b95fa8edac223d26156

commit 858f25f0dd3c7013e4c87b95fa8edac223d26156
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Sep 24 17:36:07 2019 -0600

    Remove make_hex_string
    
    I noticed that make_hex_string does essentially the same thing as
    bin2hex, and furthermore is only called in a single spot.  This patch
    removes make_hex_string.
    
    Tested by the builtbot.
    
    gdb/ChangeLog
    2019-09-25  Tom Tromey  <tom@tromey.com>
    
    	* python/py-objfile.c (objfpy_get_build_id): Use bin2hex.
    	* utils.h (make_hex_string): Don't declare.
    	* utils.c (make_hex_string): Remove.

Diff:
---
 gdb/ChangeLog           |  6 ++++++
 gdb/python/py-objfile.c |  5 ++---
 gdb/utils.c             | 16 ----------------
 gdb/utils.h             |  5 -----
 4 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee53e9c..81f5785 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-25  Tom Tromey  <tom@tromey.com>
+
+	* python/py-objfile.c (objfpy_get_build_id): Use bin2hex.
+	* utils.h (make_hex_string): Don't declare.
+	* utils.c (make_hex_string): Remove.
+
 2019-09-24  Tom de Vries  <tdevries@suse.de>
 
 	PR gdb/23815
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 2c54845..517ed56 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -141,10 +141,9 @@ objfpy_get_build_id (PyObject *self, void *closure)
 
   if (build_id != NULL)
     {
-      gdb::unique_xmalloc_ptr<char> hex_form
-	(make_hex_string (build_id->data, build_id->size));
+      std::string hex_form = bin2hex (build_id->data, build_id->size);
 
-      return host_string_to_python_string (hex_form.get ()).release ();
+      return host_string_to_python_string (hex_form.c_str ()).release ();
     }
 
   Py_RETURN_NONE;
diff --git a/gdb/utils.c b/gdb/utils.c
index b2535eb..154fcd9 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -736,22 +736,6 @@ gdb_print_host_address_1 (const void *addr, struct ui_file *stream)
   fprintf_filtered (stream, "%s", host_address_to_string (addr));
 }
 
-/* See utils.h.  */
-
-char *
-make_hex_string (const gdb_byte *data, size_t length)
-{
-  char *result = (char *) xmalloc (length * 2 + 1);
-  char *p;
-  size_t i;
-
-  p = result;
-  for (i = 0; i < length; ++i)
-    p += xsnprintf (p, 3, "%02x", data[i]);
-  *p = '\0';
-  return result;
-}
-
 \f
 
 /* An RAII class that sets up to handle input and then tears down
diff --git a/gdb/utils.h b/gdb/utils.h
index 7cdc73e..b0b5573 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -540,11 +540,6 @@ extern void warn_cant_dump_core (const char *reason);
 
 extern void dump_core (void);
 
-/* Return the hex string form of LENGTH bytes of DATA.
-   Space for the result is malloc'd, caller must free.  */
-
-extern char *make_hex_string (const gdb_byte *data, size_t length);
-
 /* Copy NBITS bits from SOURCE to DEST starting at the given bit
    offsets.  Use the bit order as specified by BITS_BIG_ENDIAN.
    Source and destination buffers must not overlap.  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-25 15:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 15:54 [binutils-gdb] Remove make_hex_string Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).