Fix a potential segfault
_Apparently_ there are "rules" that say we can't just modify const data in place >.>
This commit is contained in:
parent
fe3b71908e
commit
c32fe79d4b
1 changed files with 4 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||||
|
|
||||||
pub const title = "Day 04: Printing Department";
|
pub const title = "Day 04: Printing Department";
|
||||||
|
|
||||||
pub fn run(_: std.mem.Allocator) !void {
|
pub fn run(allocator: std.mem.Allocator) !void {
|
||||||
const initial_input = @embedFile("./input/day04.txt");
|
const initial_input = @embedFile("./input/day04.txt");
|
||||||
//const initial_input =
|
//const initial_input =
|
||||||
// \\..@@.@@@@.
|
// \\..@@.@@@@.
|
||||||
|
|
@ -17,7 +17,9 @@ pub fn run(_: std.mem.Allocator) !void {
|
||||||
// \\@.@.@@@.@.
|
// \\@.@.@@@.@.
|
||||||
// ;
|
// ;
|
||||||
|
|
||||||
const input: []u8 = @constCast(initial_input);
|
const input = try allocator.alloc(u8, initial_input.len);
|
||||||
|
defer allocator.free(input);
|
||||||
|
@memcpy(input, initial_input);
|
||||||
|
|
||||||
var accumulator: u32 = 0;
|
var accumulator: u32 = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue