aboutsummaryrefslogtreecommitdiff
path: root/gdb/xml-support.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2017-08-17 13:58:01 -0700
committerKeith Seitz <keiths@redhat.com>2017-08-17 13:58:01 -0700
commitb5f28d7abc02ca509e389fa932d725cf111e4b40 (patch)
tree57a0dc0feaff890630a6ba2c9fab811d56b1f9cf /gdb/xml-support.c
parent2a95a158fae932f758d75a1178a40d4cc4804ff0 (diff)
parent1a457753cfad05989574c671a221ffce2d5df703 (diff)
downloadbinutils-users/pmuldoon/c++compile.zip
binutils-users/pmuldoon/c++compile.tar.gz
binutils-users/pmuldoon/c++compile.tar.bz2
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/xml-support.c')
-rw-r--r--gdb/xml-support.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index fff3997..65638b9 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -1001,7 +1001,7 @@ char *
xml_fetch_content_from_file (const char *filename, void *baton)
{
const char *dirname = (const char *) baton;
- FILE *file;
+ gdb_file_up file;
struct cleanup *back_to;
char *text;
size_t len, offset;
@@ -1021,21 +1021,19 @@ xml_fetch_content_from_file (const char *filename, void *baton)
if (file == NULL)
return NULL;
- back_to = make_cleanup_fclose (file);
-
/* Read in the whole file, one chunk at a time. */
len = 4096;
offset = 0;
text = (char *) xmalloc (len);
- make_cleanup (free_current_contents, &text);
+ back_to = make_cleanup (free_current_contents, &text);
while (1)
{
size_t bytes_read;
/* Continue reading where the last read left off. Leave at least
one byte so that we can NUL-terminate the result. */
- bytes_read = fread (text + offset, 1, len - offset - 1, file);
- if (ferror (file))
+ bytes_read = fread (text + offset, 1, len - offset - 1, file.get ());
+ if (ferror (file.get ()))
{
warning (_("Read error from \"%s\""), filename);
do_cleanups (back_to);
@@ -1044,14 +1042,13 @@ xml_fetch_content_from_file (const char *filename, void *baton)
offset += bytes_read;
- if (feof (file))
+ if (feof (file.get ()))
break;
len = len * 2;
text = (char *) xrealloc (text, len);
}
- fclose (file);
discard_cleanups (back_to);
text[offset] = '\0';