diff options
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/remote.c | 22 |
2 files changed, 13 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dd01ce3..b697326 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2018-05-25 Tom Tromey <tom@tromey.com> + * remote.c (remote_target::remote_file_get): Use + gdb::byte_vector. + (remote_target::remote_file_put): Likewise. + +2018-05-25 Tom Tromey <tom@tromey.com> + * coff-pe-read.c (struct read_pe_section_data) <section_name>: Now a std::string. (get_pe_section_index, add_pe_exported_sym): Update. diff --git a/gdb/remote.c b/gdb/remote.c index 38ba7b5..e7ade41 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -12599,9 +12599,7 @@ void remote_target::remote_file_put (const char *local_file, const char *remote_file, int from_tty) { - struct cleanup *back_to; int retcode, remote_errno, bytes, io_size; - gdb_byte *buffer; int bytes_in_buffer; int saw_eof; ULONGEST offset; @@ -12621,8 +12619,7 @@ remote_target::remote_file_put (const char *local_file, const char *remote_file, /* Send up to this many bytes at once. They won't all fit in the remote packet limit, so we'll transfer slightly fewer. */ io_size = get_remote_packet_size (); - buffer = (gdb_byte *) xmalloc (io_size); - back_to = make_cleanup (xfree, buffer); + gdb::byte_vector buffer (io_size); bytes_in_buffer = 0; saw_eof = 0; @@ -12631,7 +12628,7 @@ remote_target::remote_file_put (const char *local_file, const char *remote_file, { if (!saw_eof) { - bytes = fread (buffer + bytes_in_buffer, 1, + bytes = fread (buffer.data () + bytes_in_buffer, 1, io_size - bytes_in_buffer, file.get ()); if (bytes == 0) @@ -12654,7 +12651,7 @@ remote_target::remote_file_put (const char *local_file, const char *remote_file, bytes += bytes_in_buffer; bytes_in_buffer = 0; - retcode = remote_hostio_pwrite (fd.get (), buffer, bytes, + retcode = remote_hostio_pwrite (fd.get (), buffer.data (), bytes, offset, &remote_errno); if (retcode < 0) @@ -12666,7 +12663,7 @@ remote_target::remote_file_put (const char *local_file, const char *remote_file, /* Short write. Save the rest of the read data for the next write. */ bytes_in_buffer = bytes - retcode; - memmove (buffer, buffer + retcode, bytes_in_buffer); + memmove (buffer.data (), buffer.data () + retcode, bytes_in_buffer); } offset += retcode; @@ -12677,7 +12674,6 @@ remote_target::remote_file_put (const char *local_file, const char *remote_file, if (from_tty) printf_filtered (_("Successfully sent file \"%s\".\n"), local_file); - do_cleanups (back_to); } void @@ -12695,9 +12691,7 @@ void remote_target::remote_file_get (const char *remote_file, const char *local_file, int from_tty) { - struct cleanup *back_to; int remote_errno, bytes, io_size; - gdb_byte *buffer; ULONGEST offset; scoped_remote_fd fd @@ -12714,13 +12708,12 @@ remote_target::remote_file_get (const char *remote_file, const char *local_file, /* Send up to this many bytes at once. They won't all fit in the remote packet limit, so we'll transfer slightly fewer. */ io_size = get_remote_packet_size (); - buffer = (gdb_byte *) xmalloc (io_size); - back_to = make_cleanup (xfree, buffer); + gdb::byte_vector buffer (io_size); offset = 0; while (1) { - bytes = remote_hostio_pread (fd.get (), buffer, io_size, offset, + bytes = remote_hostio_pread (fd.get (), buffer.data (), io_size, offset, &remote_errno); if (bytes == 0) /* Success, but no bytes, means end-of-file. */ @@ -12730,7 +12723,7 @@ remote_target::remote_file_get (const char *remote_file, const char *local_file, offset += bytes; - bytes = fwrite (buffer, 1, bytes, file.get ()); + bytes = fwrite (buffer.data (), 1, bytes, file.get ()); if (bytes == 0) perror_with_name (local_file); } @@ -12740,7 +12733,6 @@ remote_target::remote_file_get (const char *remote_file, const char *local_file, if (from_tty) printf_filtered (_("Successfully fetched file \"%s\".\n"), remote_file); - do_cleanups (back_to); } void |