From aa78b3b28aeff4bb9977a313f5a8002d920b34c5 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Mon, 29 Jun 2015 10:45:47 -0400 Subject: Use gdbarch obstack to allocate the TYPE_NAME string in arch_type Since the type whose name is being set is now being allocated on the gdbarch obstack, we should allocate its TYPE_NAME on the obstack too. This reduces the number of individual valgrind warnings for the command "gdb gdb" from ~300 to ~150. Tested on x86_64-unknown-linux-gnu. gdb/ChangeLog: * gdbarch.h (gdbarch_obstack_strdup): Declare. * gdbarch.c (gdbarch_obstack_strdup): Define. * gdbtypes.c (arch_type): Use it. --- gdb/gdbarch.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gdb/gdbarch.c') diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 0d4142b..37ce22a 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -449,6 +449,16 @@ gdbarch_obstack_zalloc (struct gdbarch *arch, long size) return data; } +/* See gdbarch.h. */ + +char * +gdbarch_obstack_strdup (struct gdbarch *gdbarch, const char *string) +{ + char *obstring = gdbarch_obstack_zalloc (gdbarch, strlen (string) + 1); + strcpy (obstring, string); + return obstring; +} + /* Free a gdbarch struct. This should never happen in normal operation --- once you've created a gdbarch, you keep it around. -- cgit v1.1