31 #if !(_POSIX_C_SOURCE >= 200809L) 33 #ifndef LELY_LIBC_GETDELIM_SIZE 34 #define LELY_LIBC_GETDELIM_SIZE 64 39 getdelim(
char **lineptr,
size_t *n,
int delim, FILE *stream)
51 size_t size = LELY_LIBC_GETDELIM_SIZE;
57 if (*n - (cp - *lineptr) < 2) {
61 while (size < (
size_t)(cp - *lineptr + 2))
63 char *tmp = realloc(*lineptr, size);
69 size = cp - *lineptr + 2;
70 tmp = realloc(*lineptr, size);
74 cp = tmp + (cp - *lineptr);
78 int c = fgetc(stream);
82 if (c == EOF && (ferror(stream) || !(cp - *lineptr)))
84 if (c == EOF || (*cp++ = c) == delim)
93 getline(
char **lineptr,
size_t *n, FILE *stream)
95 return getdelim(lineptr, n,
'\n', stream);
98 #endif // !(_POSIX_C_SOURCE >= 200809L) 100 #if !defined(_GNU_SOURCE) 120 int n = vsnprintf(NULL, 0, fmt, aq);
125 char *s = malloc(n + 1);
129 n = vsnprintf(s, n + 1, fmt, ap);
141 #endif // !_GNU_SOURCE 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.h> and defines any missing functionality.
int asprintf(char **strp, const char *fmt,...)
Equivalent to sprintf(), 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 <stdlib.h> and defines any missing functionality.
This is the internal header file of the C11 and POSIX compatibility library.