diff options
author | Keith Seitz <keiths@redhat.com> | 2017-08-17 13:58:01 -0700 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2017-08-17 13:58:01 -0700 |
commit | b5f28d7abc02ca509e389fa932d725cf111e4b40 (patch) | |
tree | 57a0dc0feaff890630a6ba2c9fab811d56b1f9cf /gdb/valarith.c | |
parent | 2a95a158fae932f758d75a1178a40d4cc4804ff0 (diff) | |
parent | 1a457753cfad05989574c671a221ffce2d5df703 (diff) | |
download | binutils-users/pmuldoon/c++compile.zip binutils-users/pmuldoon/c++compile.tar.gz binutils-users/pmuldoon/c++compile.tar.bz2 |
Update w/HEADusers/pmuldoon/c++compile
Problems:
gdb/compile/compile.c
gdb/cp-support.c
gdb/cp-support.h
gdb/gdbtypes.h
gdb/language.c
gdb/linespec.c
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 985233c..9724aca 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -697,12 +697,9 @@ value_concat (struct value *arg1, struct value *arg2) if (TYPE_CODE (type2) == TYPE_CODE_STRING || TYPE_CODE (type2) == TYPE_CODE_CHAR) { - struct cleanup *back_to; - count = longest_to_int (value_as_long (inval1)); inval2len = TYPE_LENGTH (type2); - ptr = (char *) xmalloc (count * inval2len); - back_to = make_cleanup (xfree, ptr); + std::vector<char> ptr (count * inval2len); if (TYPE_CODE (type2) == TYPE_CODE_CHAR) { char_type = type2; @@ -711,7 +708,7 @@ value_concat (struct value *arg1, struct value *arg2) value_contents (inval2)); for (idx = 0; idx < count; idx++) { - *(ptr + idx) = inchar; + ptr[idx] = inchar; } } else @@ -720,12 +717,11 @@ value_concat (struct value *arg1, struct value *arg2) for (idx = 0; idx < count; idx++) { - memcpy (ptr + (idx * inval2len), value_contents (inval2), + memcpy (&ptr[idx * inval2len], value_contents (inval2), inval2len); } } - outval = value_string (ptr, count * inval2len, char_type); - do_cleanups (back_to); + outval = value_string (ptr.data (), count * inval2len, char_type); } else if (TYPE_CODE (type2) == TYPE_CODE_BOOL) { @@ -739,8 +735,6 @@ value_concat (struct value *arg1, struct value *arg2) else if (TYPE_CODE (type1) == TYPE_CODE_STRING || TYPE_CODE (type1) == TYPE_CODE_CHAR) { - struct cleanup *back_to; - /* We have two character strings to concatenate. */ if (TYPE_CODE (type2) != TYPE_CODE_STRING && TYPE_CODE (type2) != TYPE_CODE_CHAR) @@ -749,31 +743,29 @@ value_concat (struct value *arg1, struct value *arg2) } inval1len = TYPE_LENGTH (type1); inval2len = TYPE_LENGTH (type2); - ptr = (char *) xmalloc (inval1len + inval2len); - back_to = make_cleanup (xfree, ptr); + std::vector<char> ptr (inval1len + inval2len); if (TYPE_CODE (type1) == TYPE_CODE_CHAR) { char_type = type1; - *ptr = (char) unpack_long (type1, value_contents (inval1)); + ptr[0] = (char) unpack_long (type1, value_contents (inval1)); } else { char_type = TYPE_TARGET_TYPE (type1); - memcpy (ptr, value_contents (inval1), inval1len); + memcpy (ptr.data (), value_contents (inval1), inval1len); } if (TYPE_CODE (type2) == TYPE_CODE_CHAR) { - *(ptr + inval1len) = + ptr[inval1len] = (char) unpack_long (type2, value_contents (inval2)); } else { - memcpy (ptr + inval1len, value_contents (inval2), inval2len); + memcpy (&ptr[inval1len], value_contents (inval2), inval2len); } - outval = value_string (ptr, inval1len + inval2len, char_type); - do_cleanups (back_to); + outval = value_string (ptr.data (), inval1len + inval2len, char_type); } else if (TYPE_CODE (type1) == TYPE_CODE_BOOL) { |