diff options
author | Tom Tromey <tom@tromey.com> | 2019-07-13 12:13:15 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-08-06 20:08:48 -0600 |
commit | 0cf9feb996cb32939840b13073a49310b1fd71e0 (patch) | |
tree | 4587051d5f873efbc2eacf85e23f2987f24d7571 /gdb/stabsread.c | |
parent | efba19b06a6f2baacb3920599f970d1333ffc358 (diff) | |
download | gdb-0cf9feb996cb32939840b13073a49310b1fd71e0.zip gdb-0cf9feb996cb32939840b13073a49310b1fd71e0.tar.gz gdb-0cf9feb996cb32939840b13073a49310b1fd71e0.tar.bz2 |
Introduce obstack_strndup
This introduces obstack_strndup and changes gdb to use it.
Note that obstack_strndup works like savestring, and not exactly like
xstrndup. The difference is that obstack_strndup uses the passed-in
length, while xstrndup uses strnlen to choose the length.
gdb/ChangeLog
2019-08-06 Tom Tromey <tom@tromey.com>
* stabsread.c (patch_block_stabs, read_one_struct_field)
(read_enum_type): Use obstack_strndup.
* rust-exp.y (rust_parser::copy_name): Use obstack_strndup.
* gdb_obstack.h (obstack_strndup): Use obstack_strndup.
* dwarf2read.c (guess_full_die_structure_name)
(anonymous_struct_prefix): Use obstack_strndup.
* dbxread.c (cp_set_block_scope): Use obstack_strndup.
* c-exp.y (yylex): Use obstack_strndup.
* ada-exp.y (write_object_renaming, write_ambiguous_var)
(write_var_or_type): Use obstack_strndup.
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r-- | gdb/stabsread.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 23da5f9..48c88de 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -426,8 +426,8 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs, SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT; SYMBOL_SET_LINKAGE_NAME - (sym, (char *) obstack_copy0 (&objfile->objfile_obstack, - name, pp - name)); + (sym, obstack_strndup (&objfile->objfile_obstack, + name, pp - name)); pp += 2; if (*(pp - 1) == 'F' || *(pp - 1) == 'f') { @@ -2841,7 +2841,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp, struct gdbarch *gdbarch = get_objfile_arch (objfile); fip->list->field.name - = (const char *) obstack_copy0 (&objfile->objfile_obstack, *pp, p - *pp); + = obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp); *pp = p + 1; /* This means we have a visibility for a field coming. */ @@ -3641,7 +3641,7 @@ read_enum_type (const char **pp, struct type *type, p = *pp; while (*p != ':') p++; - name = (char *) obstack_copy0 (&objfile->objfile_obstack, *pp, p - *pp); + name = obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp); *pp = p + 1; n = read_huge_number (pp, ',', &nbits, 0); if (nbits != 0) |