diff --git a/src/index.c b/src/index.c index 6efaa18..a21f8ba 100644 --- a/src/index.c +++ b/src/index.c @@ -23,6 +23,7 @@ #include "index.h" #include "status.h" #include "easprintf.h" +#include "reply.h" // Files #include "../static/index.chtml" @@ -34,7 +35,7 @@ void content_index(mastodont_t* api) size_t status_count, statuses_html_count; struct mstdnt_status* statuses; struct mstdnt_storage storage; - char* status_format; + char* status_format, *post_box; char* output = NULL; try_post_status(api); @@ -44,14 +45,16 @@ void content_index(mastodont_t* api) status_format = "An error occured loading the timeline"; } else { - /* Construct statuses into HTML */ + // Construct statuses into HTML status_format = construct_statuses(statuses, status_count, &statuses_html_count); if (!status_format) status_format = "Error in malloc!"; cleanup = 1; } - easprintf(&output, "%s %s", data_post_html, status_format); + // Create post box + post_box = construct_post_box(NULL, "", NULL); + easprintf(&output, "%s %s", post_box, status_format); struct base_page b = { .locale = L10N_EN_US, @@ -59,11 +62,12 @@ void content_index(mastodont_t* api) .sidebar_right = NULL }; - /* Output */ + // Output render_base_page(&b); - /* Cleanup */ + // Cleanup mastodont_storage_cleanup(&storage); if (cleanup) free(status_format); + if (post_box) free(post_box); if (output) free(output); } diff --git a/src/reply.c b/src/reply.c index ab5de2e..671a2be 100644 --- a/src/reply.c +++ b/src/reply.c @@ -75,6 +75,7 @@ char* reply_status(char* id, struct mstdnt_status* status) { fprintf(stderr, "Couldn't parse regex at offset %d: %s\n", erroffset, error); free(replies); + pcre_free(re); } for (int ind = 0;;) @@ -109,5 +110,6 @@ char* reply_status(char* id, struct mstdnt_status* status) stat_reply = construct_post_box(id, replies, NULL); if (replies) free(replies); + pcre_free(re); return stat_reply; }