1 #include "stdio_impl.h"
6 #define MIN(a,b) ((a)<(b) ? (a) : (b))
8 ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restrict f)
26 z = memchr(f->rpos, delim, f->rend - f->rpos);
27 k = z ? z - f->rpos + 1 : f->rend - f->rpos;
29 if (k >= SIZE_MAX/2-i) goto oom;
31 if (*n < SIZE_MAX/4) *n *= 2;
32 tmp = realloc(*s, *n);
35 tmp = realloc(*s, *n);
40 memcpy(*s+i, f->rpos, k);
44 if ((c = getc_unlocked(f)) == EOF) {
51 if (((*s)[i++] = c) == delim) break;
64 weak_alias(getdelim, __getdelim);