[PATCH] Replace some uses of xstrprintf with string_printf
Tom Tromey
tom@tromey.com
Tue Aug 7 15:53:00 GMT 2018
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
Simon> From: Simon Marchi <simon.marchi@ericsson.com>
Simon> This patch replaces some simple uses of xstrprintf with with
Simon> string_printf, removing the need to do manual memory freeing.
Simon> The change in ada-lang.c fixes an apparent memory leak.
FWIW, I read this patch and I think it is good.
Simon> + std::string message
Simon> + = string_printf (_("<unknown type in %s, CU %s, DIE %s>"),
Simon> + objfile_name (objfile),
Simon> + sect_offset_str (cu->header.sect_off),
Simon> + sect_offset_str (die->sect_off));
Simon> saved = (char *) obstack_copy0 (&objfile->objfile_obstack,
gnulib (and glibc) have an obstack_printf function, which would perhaps
avoid some allocations here.
However, I don't know if it is practical to import the gnulib
obstack_printf, because presumably it would want the gnulib obstack code
generally, and gdb is using the obstack from libiberty.
In the long run I tend to think it would be better to promote gnulib to
the top level and remove some things from libiberty. But that seems
like a pretty big project.
Tom
More information about the Gdb-patches
mailing list