diff options
author | Pedro Alves <pedro@palves.net> | 2021-07-15 10:47:56 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2021-07-15 15:10:59 +0100 |
commit | 50991aaf22b03a9925ae37155f16bc8257f95242 (patch) | |
tree | db0d641ebab1211d0f79c5dc00062c0708ad5b60 /gdb/c-lang.c | |
parent | 67ea24cb99efcd50d8acb6ce3e3ffbd8c97f0829 (diff) | |
download | binutils-users/palves/value_string.zip binutils-users/palves/value_string.tar.gz binutils-users/palves/value_string.tar.bz2 |
all languagesusers/palves/value_string
Change-Id: I79ef914087dbf85e1cbc19263843a6034383afe7
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r-- | gdb/c-lang.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 98f4984..d30cebe 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -653,16 +653,11 @@ c_string_operation::evaluate (struct type *expect_type, } else { - int i; - - /* Write the terminating character. */ - for (i = 0; i < TYPE_LENGTH (type); ++i) - obstack_1grow (&output, 0); + int element_size = TYPE_LENGTH (type); if (satisfy_expected) { LONGEST low_bound, high_bound; - int element_size = TYPE_LENGTH (type); if (!get_discrete_bounds (expect_type->index_type (), &low_bound, &high_bound)) @@ -677,10 +672,13 @@ c_string_operation::evaluate (struct type *expect_type, result = allocate_value (expect_type); memcpy (value_contents_raw (result), obstack_base (&output), obstack_object_size (&output)); + /* Write the terminating character. */ + memset (value_contents_raw (result) + obstack_object_size (&output), + 0, element_size); } else result = value_cstring ((const char *) obstack_base (&output), - obstack_object_size (&output), + obstack_object_size (&output) / element_size, type); } return result; |