1 /* The original code is public domain -- Will Hartung 4/9/09 */
2 /* Modifications, public domain as well, by Antti Haapala, 11/10/17
3 - Switched to getc on 5/23/19 */
4 /* Modifications, public domain, by Elias Fleckenstein 24/04/2022 */
10 // if typedef doesn't exist (msvc, blah)
11 typedef intptr_t ssize_t;
13 ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
17 if (lineptr == NULL || stream == NULL || n == NULL) {
27 if (*lineptr == NULL) {
28 *lineptr = malloc(128);
29 if (*lineptr == NULL) {
38 size_t new_size = *n + (*n >> 2);
42 char *new_ptr = realloc(*lineptr, new_size);
43 if (new_ptr == NULL) {
50 ((unsigned char *)(*lineptr))[pos ++] = c;
57 (*lineptr)[pos] = '\0';