34#if !(_POSIX_C_SOURCE >= 200809L)
36#ifndef LELY_LIBC_GETDELIM_SIZE
38#define LELY_LIBC_GETDELIM_SIZE 64
42getdelim(
char **lineptr,
size_t *n,
int delim, FILE *stream)
54 size_t size = LELY_LIBC_GETDELIM_SIZE;
60 if (*n - (cp - *lineptr) < 2) {
64 while (size < (
size_t)(cp - *lineptr + 2))
66 char *tmp = realloc(*lineptr, size);
72 size = cp - *lineptr + 2;
73 tmp = realloc(*lineptr, size);
77 cp = tmp + (cp - *lineptr);
81 int c = fgetc(stream);
85 if (c == EOF && (ferror(stream) || !(cp - *lineptr)))
87 if (c == EOF || (*cp++ = c) == delim)
96getline(
char **lineptr,
size_t *n, FILE *stream)
98 return getdelim(lineptr, n,
'\n', stream);
103#if !defined(_GNU_SOURCE)
123 int n = vsnprintf(NULL, 0, fmt, aq);
128 char *s = malloc(n + 1);
132 n = vsnprintf(s, n + 1, fmt, ap);
This is the internal header file of the C11 and POSIX compatibility library.
int asprintf(char **strp, const char *fmt,...)
Equivalent to sprintf(), except that it allocates a string large enough to hold the output,...
int vasprintf(char **strp, const char *fmt, va_list ap)
Equivalent to vsprintf(), except that it allocates a string large enough to hold the output,...
This header file is part of the C11 and POSIX compatibility library; it includes <stdio....
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....