From 012ed5bd6455ce291741ad540a5e356e4810133b Mon Sep 17 00:00:00 2001 From: wrmr Date: Fri, 8 Nov 2024 23:25:03 -0500 Subject: use strv_t for doc_add_text, remove doc_add_textn, add strv() --- doc.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'doc.c') diff --git a/doc.c b/doc.c index 97d8b34..d43ff30 100644 --- a/doc.c +++ b/doc.c @@ -39,20 +39,16 @@ void doc_new_line(struct doc *d) { } void doc_add_line(struct doc *d, strv_t s) { - doc_add_textn(d, s.s, s.n); + doc_add_text(d, s); doc_new_line(d); } -void doc_add_text(struct doc *d, const char *s) { - doc_add_textn(d, s, strlen(s)); -} - -void doc_add_textn(struct doc *d, const char *s, size_t n) { - buf_grow(&d->txt, n); - memcpy(&d->txt.buf[d->txt.sz], s, n); +void doc_add_text(struct doc *d, strv_t s) { + buf_grow(&d->txt, s.n); + memcpy(&d->txt.buf[d->txt.sz], s.s, s.n); struct doc_line *dl = (struct doc_line *)&d->txt.buf[d->latest]; - d->txt.sz += n; - dl->len += n; + d->txt.sz += s.n; + dl->len += s.n; } unsigned short doc_add_link(struct doc *d, const char *url) { -- cgit 1.4.1-2-gfad0