Switch to post box, cleanup regex

FossilOrigin-Name: 1819fb7b574fdf58b1906b6be7d79357f4a69d0121be6647954aa018073d7531
This commit is contained in:
me@ow.nekobit.net 2022-02-26 06:23:34 +00:00
parent c8ee06b4a5
commit 87dfa05fbf
2 changed files with 11 additions and 5 deletions

View file

@ -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);
}

View file

@ -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;
}