commit ca5da9383a5f53fa258d98630aebcad191e8bd88 from: Omar Polo date: Thu Apr 01 08:00:33 2021 UTC free page contents on do_load_link to do that, move empty_vlist to wrap.c and provide a similar function for struct line*s. commit - 7a014cef1da3f4ee60cdaa8be78eb7a0fe97e1a8 commit + ca5da9383a5f53fa258d98630aebcad191e8bd88 blob - 6459d502e21aaa62b46950634fa9708805486cf3 blob + 6dc5f5b56eb5202d22b9c7e460388325acec7501 --- telescope.c +++ telescope.c @@ -368,6 +368,9 @@ do_load_url(struct tab *tab, const char *url) } protos[0].loadfn(tab, url); + + empty_vlist(&tab->window); + empty_linelist(&tab->window); } void blob - a96c2291c4d5e5c7a0c2cd4b7827e7a9e0330e58 blob + 6a359b37e8369f9d9c2dc88667d3f919637041b3 --- telescope.h +++ telescope.h @@ -274,6 +274,8 @@ int unicode_isgraph(uint32_t); void dispatch_imsg(struct imsgbuf*, imsg_handlerfn**, size_t); /* wrap.c */ +void empty_linelist(struct window*); +void empty_vlist(struct window*); int wrap_text(struct window*, const char*, struct line*, size_t); int hardwrap_text(struct window*, struct line*, size_t); blob - c7c31b2ba3559b5785177845363f4f15d6c62a5f blob + f4f28f59da3378246dd72eaf176086080d097b62 --- ui.c +++ ui.c @@ -53,7 +53,6 @@ static struct event stdioev, winchev; static void load_default_keys(void); -static void empty_vlist(struct window*); static void restore_cursor(struct window*); #define CMD(fnname) static void fnname(struct window *) @@ -236,22 +235,7 @@ static struct tab_face { } tab_face = { A_REVERSE, A_REVERSE, A_NORMAL }; - -static void -empty_vlist(struct window *window) -{ - struct vline *vl, *t; - - window->current_line = NULL; - window->line_max = 0; - TAILQ_FOREACH_SAFE(vl, &window->head, vlines, t) { - TAILQ_REMOVE(&window->head, vl, vlines); - free(vl->line); - free(vl); - } -} - static inline void global_set_key(const char *key, void (*fn)(struct window*)) { blob - f5f79bcaa3f3261bf1b965178514c4a976559398 blob + f5c483c9b31de62b76a4b7a20f877fd2db080aa9 --- wrap.c +++ wrap.c @@ -35,6 +35,34 @@ * */ +void +empty_linelist(struct window *window) +{ + struct line *l, *lt; + + TAILQ_FOREACH_SAFE(l, &window->page.head, lines, lt) { + TAILQ_REMOVE(&window->page.head, l, lines); + free(l->line); + free(l->alt); + free(l); + } +} + +void +empty_vlist(struct window *window) +{ + struct vline *vl, *t; + + window->current_line = NULL; + window->line_max = 0; + + TAILQ_FOREACH_SAFE(vl, &window->head, vlines, t) { + TAILQ_REMOVE(&window->head, vl, vlines); + free(vl->line); + free(vl); + } +} + static int push_line(struct window *window, const struct line *l, const char *buf, size_t len, int cont) {