#include <stdio.h>
Go to the source code of this file.
|
ssize_t | getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) |
|
◆ getline
#define getline |
( |
|
lineptr, |
|
|
|
n, |
|
|
|
stream |
|
) |
| getdelim (lineptr, n, '\n', stream) |
◆ getdelim()
ssize_t getdelim |
( |
char ** |
lineptr, |
|
|
size_t * |
n, |
|
|
int |
delimiter, |
|
|
FILE * |
fp |
|
) |
| |
71 if (*lineptr ==
NULL || *n == 0) {
73 *lineptr = (
char *) malloc(*n);
74 if (*lineptr ==
NULL) {
90 if (cur_len + 1 >= *n) {
93 size_t needed = 2 * *n + 1;
96 if (needed_max < needed)
98 if (cur_len + 1 >= needed) {
103 new_lineptr = (
char *) realloc (*lineptr, needed);
104 if (new_lineptr ==
NULL) {
109 *lineptr = new_lineptr;
113 (*lineptr)[cur_len] =
i;
116 if (
i == delimiter)
break;
118 (*lineptr)[cur_len] =
'\0';
119 result = cur_len ? (
int) cur_len : (
int) result;