fix memory issues in day 1
This commit is contained in:
parent
3d7ce59cbd
commit
bcc674bdf1
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue