From 21b6dd0b6396d50ee6fe4068accc70ec8df2a519 Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Sun, 23 Aug 2026 14:01:16 +0100 Subject: [PATCH] now using temp_allocator for string stuff in gen. blog index for mem safety --- gen.odin | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/gen.odin b/gen.odin index 303666b..5a100cb 100644 --- a/gen.odin +++ b/gen.odin @@ -44,19 +44,28 @@ generate_blog_md_file :: proc(path: string, allocator := context.allocator) { // *********** BLOG PARSING ************** for blog in blogs { - b := strings.split(blog, blog_dir, allocator) + b := strings.split(blog, blog_dir, allocator = context.temp_allocator) trim_b := strings.trim_right(b[1], ".md") - if trim_b == "index" {continue} //Ignore Index + if trim_b == "index" {continue} //Ignore Index if strings.starts_with(trim_b, "!") {continue} //Ignore WIP files! + + // now add to blog list append(&blog_list, blog) + + free_all(context.temp_allocator) } + // sck: note we are doing this in reverse - means the blogs are ordered + // from oldest at the bottom and newest at the top #reverse for blog_entry in blog_list { - b := strings.split(blog_entry, blog_dir, allocator) + b := strings.split(blog_entry, blog_dir, allocator = context.temp_allocator) trim_b := strings.trim_right(b[1], ".md") - strings.write_string(&blog_md_file, fmt.aprintf("* [%s](./%s.html)", trim_b, trim_b, allocator = allocator)) + + strings.write_string(&blog_md_file, fmt.aprintf("* [%s](./%s.html)", trim_b, trim_b, allocator = context.temp_allocator)) strings.write_string(&blog_md_file, "\n") + + free_all(context.temp_allocator) } os.change_directory(blog_dir) @@ -64,7 +73,12 @@ generate_blog_md_file :: proc(path: string, allocator := context.allocator) { if err != nil { fmt.eprintfln("ERROR in generate_blog_md_file: Could not open file %s: %s", index_file, os.error_string(err)) } - os.write_string(index_file, "```") + + // sck: final step, write everything in the correct order for the index.html page + // note: we generate the MD file for the blog/index.md + // this saves me time from ordering the blog and allows for automagic + // indexing of blogs/articles + os.write_string(index_file, "```text") os.write_string(index_file, BLOG_START_MD) os.write_string(index_file, "```\n") os.write_string(index_file, BLOG_TITLE_MD)