9 #include <platon/str/dynfgets.h>
12 PLATON_FUNC(dynamic_fgets)(fp)
15 char temp[DYNAMIC_FGETS_BUFSIZE];
19 if ((ptr = (char *) malloc(1)) == NULL)
22 for (*ptr = '\0', i = 0; ; i++) {
23 if (fgets(temp, DYNAMIC_FGETS_BUFSIZE, fp) == NULL) {
24 if (ferror(fp) != 0 || i == 0) {
32 ptr = (char *) realloc(ptr, (DYNAMIC_FGETS_BUFSIZE - 1) * (i + 1) + 1);
38 if (strchr(temp, '\n') != NULL) {
39 *strchr(ptr, '\n') = '\0';