Skip to content

Commit

Permalink
Valgrind fixenings
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Dec 12, 2024
1 parent dbe0164 commit c330664
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/aoc2024/day08/part1.jou
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def main() -> int:
*p = '.'

freqs: byte[100]
memset(&freqs, 0, sizeof(freqs))
nfreqs = 0
for p = antennas.data; *p != '\0'; p++:
if *p != '.' and *p != '\n' and strchr(freqs, *p) == NULL:
assert nfreqs < sizeof(freqs)/sizeof(freqs[0])
assert nfreqs + 1 < sizeof(freqs)/sizeof(freqs[0])
freqs[nfreqs++] = *p

for i = 0; i < nfreqs; i++:
Expand Down
3 changes: 2 additions & 1 deletion examples/aoc2024/day08/part2.jou
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ def main() -> int:
*p = '.'

freqs: byte[100]
memset(&freqs, 0, sizeof(freqs))
nfreqs = 0
for p = antennas.data; *p != '\0'; p++:
if *p != '.' and *p != '\n' and strchr(freqs, *p) == NULL:
assert nfreqs < sizeof(freqs)/sizeof(freqs[0])
assert nfreqs + 1 < sizeof(freqs)/sizeof(freqs[0])
freqs[nfreqs++] = *p

for i = 0; i < nfreqs; i++:
Expand Down
1 change: 1 addition & 0 deletions examples/aoc2024/day11/part1.jou
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ def main() -> int:
nstones = blink(stones, nstones)
printf("%d\n", nstones) # Output: 55312

free(stones)
return 0
2 changes: 2 additions & 0 deletions examples/aoc2024/day12/part1.jou
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@ def main() -> int:
result += (fence1 + fence2) * area

printf("%d\n", result) # Output: 1930

free(grid.data)
return 0
2 changes: 2 additions & 0 deletions examples/aoc2024/day12/part2.jou
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ def main() -> int:
result += (fence1 + fence2) * area

printf("%d\n", result) # Output: 368

free(grid.data)
return 0

0 comments on commit c330664

Please sign in to comment.