From bcc674bdf1a18ffb44c56a95e2ff76e9590b4829 Mon Sep 17 00:00:00 2001 From: Parker Macdonald Date: Sat, 7 Dec 2024 16:27:55 -0700 Subject: [PATCH] fix memory issues in day 1 --- day 1/1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/day 1/1.c b/day 1/1.c index 9a38b27..7808f4d 100644 --- a/day 1/1.c +++ b/day 1/1.c @@ -24,9 +24,9 @@ int main(void) { rewind(fp); // get data from file - int* left = malloc(lineCount * 2 * sizeof(int)); + int* left = malloc((lineCount * 2 + 1) * sizeof(int)); // haha pointer arithmetic go brrr - int* right = left + lineCount * sizeof(int); + int* right = left + lineCount; for (size_t i = 0; i < lineCount; i++) { int leftNum, rightNum;