From 137fd441e115245e27e526b4183e2c575b20dd84 Mon Sep 17 00:00:00 2001 From: Lucia Ceionia Date: Wed, 3 Dec 2025 17:33:25 -0600 Subject: [PATCH] no more crash on day3 --- Makefile | 4 ++-- day3.c | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 50519a1..8147689 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ FILES = $(wildcard ./*) SRCS = $(filter %.c,$(FILES)) BINS = $(SRCS:%.c=%.elf) -CFLAGS = -Wall -Werror -pedantic -D_GNU_SOURCE -std=gnu2y -O3 -g -Wno-unused\ - -nostartfiles -static -Ttext=C475000 +CFLAGS = -Wall -Werror -pedantic -Wno-unused -D_GNU_SOURCE -std=gnu2y\ + -O3 -g -Ttext=C475000 -static -nostartfiles -fno-stack-protector -march=native all: $(BINS) diff --git a/day3.c b/day3.c index 4f79b53..c39c685 100644 --- a/day3.c +++ b/day3.c @@ -49,20 +49,17 @@ unsigned long do_part2(size_t file_len, unsigned char file[file_len]) { unsigned char *s = file; do { - // for some reason this crashes - // but works fine under blink so. - // whatever unsigned char n[12] = { }; - unsigned char *np[12] = { }; + unsigned char *np = NULL; for (int i = 0; i < 12; i++) { do { if (s[0] > n[i]) { n[i] = s[0]; - np[i] = s; + np = s; } s++; } while (s[11-i] != '\n'); - s = np[i]+1; + s = np+1; } unsigned long v = 0; for (int i = 0; i < 12; i++) {