From: Brendan Hansen Date: Tue, 22 Dec 2020 16:18:09 +0000 (-0600) Subject: updated day 20 to use a ring allocator X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=14809442d12a78f139662a1685c37e2bd7d004a1;p=onyx-aoc-2020.git updated day 20 to use a ring allocator --- diff --git a/day20.onyx b/day20.onyx index 547c0bc..6cbc048 100644 --- a/day20.onyx +++ b/day20.onyx @@ -263,8 +263,12 @@ main :: proc (args: [] cstr) { tile_data := calloc(200 * sizeof TileData); defer cfree(tile_data); - tile_data_arena := alloc.arena.make(tile_data, 200 * sizeof TileData); - tile_allocator := alloc.arena.make_allocator(^tile_data_arena); + // This ring allocator could technically overflow and start + // allocating memory that isn't technically free, but there + // should be more than enough space in the allocator to not + // run into that problem... Hopefully. + tile_data_ring := alloc.ring.make(tile_data, 200 * sizeof TileData); + tile_allocator := alloc.ring.make_allocator(^tile_data_ring); while !reader.empty(^file) { reader.read_word(^file); // 'Tile '