commit 9eca3d7c1eac7c78577af884ba7bc954d2f8b969 from: Omar Polo date: Tue Nov 02 17:30:29 2021 UTC delay erase_buffer until parser_init The idea is to handle better non-displayable pages (like images), and keeping the old page until the server replies is the first step. It also simplifies the memory management btw. commit - 7e76e0efa3f677f0a044330b98590f2128789d80 commit + 9eca3d7c1eac7c78577af884ba7bc954d2f8b969 blob - 3677a37fdf65203a8209a0bbff32432245163cda blob + d86ecd198a0d9ba24726b766995f687bc6a17364 --- parser.c +++ parser.c @@ -29,7 +29,6 @@ int load_page_from_str(struct tab *tab, const char *page) { - erase_buffer(&tab->buffer); parser_init(tab, gemtext_initparser); if (!tab->buffer.page.parse(&tab->buffer.page, page, strlen(page))) abort(); @@ -43,6 +42,7 @@ load_page_from_str(struct tab *tab, const char *page) void parser_init(struct tab *tab, parserfn fn) { + erase_buffer(&tab->buffer); fn(&tab->buffer.page); } blob - 31a077546609381a7b422b13497c50095ac2e693 blob + f6d6aede5cfd8e52520e5fbc83a4f4289c2c26fb --- telescope.c +++ telescope.c @@ -802,8 +802,7 @@ gopher_send_search_req(struct tab *tab, const char *te * Effectively load the given url in the given tab. Return 1 when * loading the page asynchronously, and thus when an erase_buffer can * be done right after this function return, or 0 when loading the - * page synchronously. In this last case, erase_buffer *MUST* be - * called by the handling function (such as load_page_from_str). + * page synchronously. */ static int do_load_url(struct tab *tab, const char *url, const char *base) @@ -902,8 +901,8 @@ load_url(struct tab *tab, const char *url, const char sizeof(tab->hist_cur->h)); } - if (!lazy && do_load_url(tab, url, base)) - erase_buffer(&tab->buffer); + if (!lazy) + do_load_url(tab, url, base); } void