Prefix blogs with blog-, fix minor leaks

This commit is contained in:
kamkow1
2025-06-28 01:38:39 +02:00
parent 2988a5b3d6
commit 486952dcbf
6 changed files with 7 additions and 6 deletions

View File

@ -29,7 +29,7 @@ void make_application_json(Allocator *alloc, Route_Result *result, int code, cJS
result->status_code = code;
result->type = ROUTE_RESULT_DYNAMIC;
list_append(&result->headers, clonestr_alloc(alloc, "Content-Type: application/json"));
list_append_alloc(alloc, &result->headers, clonestr_alloc(alloc, "Content-Type: application/json"));
sb_append_nstr_alloc(alloc, &result->body, buf);
sb_finish_alloc(alloc, &result->body);
}
@ -193,7 +193,7 @@ void route_generic_blog(Allocator *alloc, struct mg_http_message *msg, Route_Res
#endif
String_Builder md = {0};
if (!sb_read_file(&md, md_path)) {
if (!sb_read_file_alloc(alloc, &md, md_path)) {
make_internal_server_error(alloc, result);
return;
}
@ -243,6 +243,7 @@ void route_generic_blog(Allocator *alloc, struct mg_http_message *msg, Route_Res
void collect_blogs(Baked_Resource *resource, void *udata)
{
struct { Allocator *alloc; String_Builder *sb; } *ud = udata;
printf("%s\n", resource->key);
if ((strlen(resource->key) >= strlen("blog-"))
&& strncmp(resource->key, "blog-", strlen("blog-")) == 0) {
sb_append_nstr_alloc(ud->alloc, ud->sb,