Index: util/romcc.c =================================================================== --- util/romcc.c (Revision 58) +++ util/romcc.c (Arbeitskopie) @@ -224,6 +224,7 @@ off_t size, progress; ssize_t result; struct stat stats; + FILE* file; if (!filename) { *r_size = 0; @@ -234,6 +235,7 @@ } xchdir(dirname); fd = open(filename, O_RDONLY); + file = fopen(filename, "rb"); xchdir(cwd); if (fd < 0) { die("Cannot open '%s' : %s\n", @@ -250,8 +252,13 @@ buf[size] = '\n'; /* Make certain the file is newline terminated */ buf[size+1] = '\0'; /* Null terminate the file for good measure */ progress = 0; + result = close(fd); + if (result < 0) { + die("Close of %s failed: %s\n", + filename, strerror(errno)); + } while(progress < size) { - result = read(fd, buf + progress, size - progress); + result = fread(buf + progress, 1, size - progress, file); if (result < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; @@ -260,11 +267,7 @@ } progress += result; } - result = close(fd); - if (result < 0) { - die("Close of %s failed: %s\n", - filename, strerror(errno)); - } + fclose(file); return buf; } @@ -15148,7 +15151,6 @@ } } memset(block, -1, sizeof(*block)); - xfree(block); } static void free_basic_blocks(struct compile_state *state,