Return unique_xmalloc_ptr from target_fileio_read_stralloc
Change target_fileio_read_stralloc to return unique_xmalloc_ptr and fix up the callers. This removes a number of cleanups. ChangeLog 2017-10-16 Tom Tromey <tom@tromey.com> * linux-tdep.c (linux_info_proc, linux_find_memory_regions_full) (linux_fill_prpsinfo, linux_vsyscall_range_raw): Update. * target.c (target_fileio_read_stralloc): Update. * sparc64-tdep.c (adi_is_addr_mapped): Update. * target.h (target_fileio_read_stralloc): Return unique_xmalloc_ptr.
This commit is contained in:
parent
b7b030adc4
commit
87028b8739
5 changed files with 64 additions and 86 deletions
|
@ -3083,7 +3083,7 @@ target_fileio_read_alloc (struct inferior *inf, const char *filename,
|
|||
|
||||
/* See target.h. */
|
||||
|
||||
char *
|
||||
gdb::unique_xmalloc_ptr<char>
|
||||
target_fileio_read_stralloc (struct inferior *inf, const char *filename)
|
||||
{
|
||||
gdb_byte *buffer;
|
||||
|
@ -3094,10 +3094,10 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename)
|
|||
bufstr = (char *) buffer;
|
||||
|
||||
if (transferred < 0)
|
||||
return NULL;
|
||||
return gdb::unique_xmalloc_ptr<char> (nullptr);
|
||||
|
||||
if (transferred == 0)
|
||||
return xstrdup ("");
|
||||
return gdb::unique_xmalloc_ptr<char> (xstrdup (""));
|
||||
|
||||
bufstr[transferred] = 0;
|
||||
|
||||
|
@ -3111,7 +3111,7 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename)
|
|||
break;
|
||||
}
|
||||
|
||||
return bufstr;
|
||||
return gdb::unique_xmalloc_ptr<char> (bufstr);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue