summary refs log tree commit diff
path: root/doc.c
diff options
context:
space:
mode:
Diffstat (limited to 'doc.c')
-rw-r--r--doc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/doc.c b/doc.c
index 658315c..d5da6bf 100644
--- a/doc.c
+++ b/doc.c
@@ -23,15 +23,14 @@ void doc_fini(struct doc *d) {
 }
 
 void doc_new_line(struct doc *d) {
-	size_t here = d->latest, there = d->txt.sz;
 	buf_grow(&d->txt, sizeof(struct doc_line));
-	*(struct doc_line *)&d->txt.buf[there] = (struct doc_line) {
-		.prev = there - here,
+	*(struct doc_line *)&d->txt.buf[d->txt.sz] = (struct doc_line) {
+		.prev = ((struct doc_line *)&d->txt.buf[d->latest])->len,
 		.link = DOC_LINK_NONE,
 		.len = 0
 	};
+	d->latest = d->txt.sz;
 	d->txt.sz += sizeof(struct doc_line);
-	d->latest = there;
 }
 
 void doc_add_line(struct doc *d, const char *s) {