no more crash on day3

This commit is contained in:
2025-12-03 17:33:25 -06:00
parent 26dd9df8c7
commit 137fd441e1
2 changed files with 5 additions and 8 deletions

View File

@@ -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)

9
day3.c
View File

@@ -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++) {