fix memory issues in day 1

This commit is contained in:
Parker Macdonald 2024-12-07 16:27:55 -07:00
parent 3d7ce59cbd
commit bcc674bdf1

View file

@ -24,9 +24,9 @@ int main(void) {
rewind(fp); rewind(fp);
// get data from file // get data from file
int* left = malloc(lineCount * 2 * sizeof(int)); int* left = malloc((lineCount * 2 + 1) * sizeof(int));
// haha pointer arithmetic go brrr // haha pointer arithmetic go brrr
int* right = left + lineCount * sizeof(int); int* right = left + lineCount;
for (size_t i = 0; i < lineCount; i++) { for (size_t i = 0; i < lineCount; i++) {
int leftNum, rightNum; int leftNum, rightNum;