diff options
| author | Tom Lane | 2020-09-22 19:55:13 +0000 |
|---|---|---|
| committer | Tom Lane | 2020-09-22 19:55:13 +0000 |
| commit | 931487018c409a3102452f965ccaa48367244a41 (patch) | |
| tree | e959b76c7754b2b7af7bfa593e1825fa0328f88d /src/bin/initdb | |
| parent | c4133ec169dfe47803656325dbfb8397f85a70ea (diff) | |
Rethink API for pg_get_line.c, one more time.
Further experience says that the appending behavior offered by
pg_get_line_append is useful to only a very small minority of callers.
For most, the requirement to reset the buffer after each line is just
an error-prone nuisance. Hence, invent another alternative call
pg_get_line_buf, which takes care of that detail.
Noted while reviewing a patch from Daniel Gustafsson.
Discussion: https://postgr.es/m/48A4FA71-524E-41B9-953A-FD04EF36E2E7@yesql.se
Diffstat (limited to 'src/bin/initdb')
| -rw-r--r-- | src/bin/initdb/initdb.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 37e0d7ceab9..118b282d1c5 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -486,7 +486,7 @@ readfile(const char *path) result = (char **) pg_malloc(maxlines * sizeof(char *)); n = 0; - while (pg_get_line_append(infile, &line)) + while (pg_get_line_buf(infile, &line)) { /* make sure there will be room for a trailing NULL pointer */ if (n >= maxlines - 1) @@ -496,8 +496,6 @@ readfile(const char *path) } result[n++] = pg_strdup(line.data); - - resetStringInfo(&line); } result[n] = NULL; |
