4 void strbuf_init(struct strbuf
*sb
) {
6 sb
->eof
= sb
->alloc
= sb
->len
= 0;
9 static void strbuf_begin(struct strbuf
*sb
) {
14 static void inline strbuf_add(struct strbuf
*sb
, int ch
) {
15 if (sb
->alloc
<= sb
->len
) {
16 sb
->alloc
= sb
->alloc
* 3 / 2 + 16;
17 sb
->buf
= xrealloc(sb
->buf
, sb
->alloc
);
19 sb
->buf
[sb
->len
++] = ch
;
22 static void strbuf_end(struct strbuf
*sb
) {
26 void read_line(struct strbuf
*sb
, FILE *fp
, int term
) {
33 while ((ch
= fgetc(fp
)) != EOF
) {
38 if (ch
== EOF
&& sb
->len
== 0)