+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
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;
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
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. */