diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-12-09 11:48:26 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-12-09 11:48:26 +0100 |
| commit | 6ee8e076d0b8630c4d78e7e88f1e44f5c7ba3854 (patch) | |
| tree | fd6dc253c524cbd71e4dba867e8ad16292f9115b /9 | |
| parent | d1aefe3ee5b1c38bc00262670fb67b1362fbc61d (diff) | |
Git commit stack alloc when sensible
Diffstat (limited to '9')
| -rw-r--r-- | 9/part1.c | 4 | ||||
| -rw-r--r-- | 9/part2.c | 4 |
2 files changed, 2 insertions, 6 deletions
@@ -2,8 +2,6 @@ #include <stdio.h> #include <stdint.h> #include <stdlib.h> -#include <malloc.h> -#include <string.h> #define INPUT_LEN 1000 #define SEARCH_LEN 25 @@ -31,7 +29,7 @@ int exe_program(const char *filename) // Include space for newline and string terminator char buffer[24] = { 0 }; - uint64_t *nums = malloc(INPUT_LEN * sizeof(uint64_t)); + uint64_t nums[INPUT_LEN]; size_t num_size = 0; while (fgets(buffer, 24, file)) { @@ -2,8 +2,6 @@ #include <stdio.h> #include <stdint.h> #include <stdlib.h> -#include <malloc.h> -#include <string.h> #define INPUT_LEN 1000 #define SEARCH_LEN 25 @@ -31,7 +29,7 @@ int exe_program(const char *filename) // Include space for newline and string terminator char buffer[24] = { 0 }; - uint64_t *nums = malloc(INPUT_LEN * sizeof(uint64_t)); + uint64_t nums[INPUT_LEN] = { 0 }; size_t num_size = 0; while (fgets(buffer, 24, file)) { |
