diff options
Diffstat (limited to 'libbb/fgets_str.c')
-rw-r--r-- | libbb/fgets_str.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libbb/fgets_str.c b/libbb/fgets_str.c index 41370d176..1bc6c3b1c 100644 --- a/libbb/fgets_str.c +++ b/libbb/fgets_str.c | |||
@@ -8,17 +8,12 @@ | |||
8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | |||
12 | #include <stdio.h> | ||
13 | #include <stdlib.h> | ||
14 | #include <string.h> | ||
15 | |||
16 | #include "libbb.h" | 11 | #include "libbb.h" |
17 | 12 | ||
18 | /* Read up to (and including) TERMINATING_STRING from FILE and return it. | 13 | /* Read up to (and including) TERMINATING_STRING from FILE and return it. |
19 | * Return NULL on EOF. */ | 14 | * Return NULL on EOF. */ |
20 | 15 | ||
21 | char *fgets_str(FILE *file, const char *terminating_string) | 16 | char *xmalloc_fgets_str(FILE *file, const char *terminating_string) |
22 | { | 17 | { |
23 | char *linebuf = NULL; | 18 | char *linebuf = NULL; |
24 | const int term_length = strlen(terminating_string); | 19 | const int term_length = strlen(terminating_string); |
@@ -36,7 +31,8 @@ char *fgets_str(FILE *file, const char *terminating_string) | |||
36 | 31 | ||
37 | /* grow the line buffer as necessary */ | 32 | /* grow the line buffer as necessary */ |
38 | while (idx > linebufsz - 2) { | 33 | while (idx > linebufsz - 2) { |
39 | linebuf = xrealloc(linebuf, linebufsz += 1000); | 34 | linebufsz += 200; |
35 | linebuf = xrealloc(linebuf, linebufsz); | ||
40 | } | 36 | } |
41 | 37 | ||
42 | linebuf[idx] = ch; | 38 | linebuf[idx] = ch; |