We don't need heap allocation

This commit is contained in:
ktkk 2025-12-04 15:58:57 +00:00
parent c32fe79d4b
commit 9ad1671195

View file

@ -2,7 +2,7 @@ const std = @import("std");
pub const title = "Day 04: Printing Department";
pub fn run(allocator: std.mem.Allocator) !void {
pub fn run(_: std.mem.Allocator) !void {
const initial_input = @embedFile("./input/day04.txt");
//const initial_input =
// \\..@@.@@@@.
@ -17,9 +17,12 @@ pub fn run(allocator: std.mem.Allocator) !void {
// \\@.@.@@@.@.
// ;
const input = try allocator.alloc(u8, initial_input.len);
defer allocator.free(input);
@memcpy(input, initial_input);
var input_buffer = comptime init: {
var temp: [initial_input.len]u8 = undefined;
@memcpy(&temp, initial_input);
break :init temp;
};
const input: []u8 = &input_buffer;
var accumulator: u32 = 0;