Skip to content

Commit

Permalink
Fix Function prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
424ever committed Dec 9, 2023
1 parent ce9ec2b commit fc108b8
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 55 deletions.
9 changes: 3 additions & 6 deletions src/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ static char expected_output[OUTPUT_SIZE];

bool register_sol(struct aoc_sol);

int main(argc, argv)
int argc;
char *argv[];
int main(int argc, char *argv[])
{
FILE *debug_out_f;
FILE *in_f;
Expand Down Expand Up @@ -179,7 +177,7 @@ char *argv[];
return ret;
}

bool register_sol(sol) struct aoc_sol sol;
bool register_sol(struct aoc_sol sol)
{
size_t i;

Expand All @@ -197,8 +195,7 @@ bool register_sol(sol) struct aoc_sol sol;
return true;
}

char *rtrim(s)
char *s;
char *rtrim(char *s)
{
char *back;

Expand Down
10 changes: 3 additions & 7 deletions src/sol/day1.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ void __attribute__((constructor)) day1_init(void)
fprintf(stderr, "day1 load failed.\n");
}

void day1_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void day1_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
char *line;
size_t i;
Expand Down Expand Up @@ -94,8 +92,7 @@ FILE *debug_out;
free(cals_arr);
}

static size_t cals_sum(cals)
struct day1_cals *cals;
static size_t cals_sum(struct day1_cals *cals)
{
size_t i;
size_t sum;
Expand All @@ -108,8 +105,7 @@ struct day1_cals *cals;
return sum;
}

static int cals_sum_compar(i1, i2) const void *i1;
const void *i2;
static int cals_sum_compar(const void *i1, const void *i2)
{
return cals_sum((struct day1_cals *) i1) -
cals_sum((struct day1_cals *) i2);
Expand Down
4 changes: 1 addition & 3 deletions src/sol/day2.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ void __attribute__((constructor)) day2_init(void)
fprintf(stderr, "day2 load failed.\n");
}

void day2_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void day2_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
char my_move;
char op_move;
Expand Down
4 changes: 1 addition & 3 deletions src/sol/day3.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ void __attribute__((constructor)) day3_init(void)
fprintf(stderr, "day3 load failed.\n");
}

void day3_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void day3_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
char common_char;
char *line;
Expand Down
12 changes: 4 additions & 8 deletions src/sol/day4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include "aoc.h"

Expand All @@ -25,9 +24,7 @@ void __attribute__((constructor)) day4_init(void)
fprintf(stderr, "day4 load failed.\n");
}

void day4_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void day4_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
size_t full_ol_count;
size_t ol_count;
Expand All @@ -50,19 +47,18 @@ FILE *debug_out;
fprintf(out_f, "%ld\n%ld\n", full_ol_count, ol_count);
}

bool overlap(r) struct region r[2];
bool overlap(struct region r[2])
{
return r[0].l <= r[1].h && r[1].l <= r[0].h;
}

bool full_overlap(r) struct region r[2];
bool full_overlap(struct region r[2])
{
return (r[0].l <= r[1].l && r[0].h >= r[1].h) ||
(r[1].l <= r[0].l && r[1].h >= r[0].h);
}

void write_reg(f, r) FILE *f;
struct region r;
void write_reg(FILE *f, struct region r)
{
fprintf(f, "reg(%d %d)\n", r.l, r.h);
}
24 changes: 7 additions & 17 deletions src/sol/day5.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ void __attribute__((constructor)) day5_init(void)
fprintf(stderr, "day5 load failed.\n");
}

void day5_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void day5_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
char *crate;
char *line;
Expand Down Expand Up @@ -123,8 +121,7 @@ FILE *debug_out;
free(line);
}

void apply_proc_1(s, p) struct stack *s;
struct proc p;
void apply_proc_1(struct stack *s, struct proc p)
{
char c;
size_t i;
Expand All @@ -136,8 +133,7 @@ struct proc p;
}
}

void apply_proc_2(s, p) struct stack *s;
struct proc p;
void apply_proc_2(struct stack *s, struct proc p)
{
char *buf;
ssize_t i;
Expand Down Expand Up @@ -166,8 +162,7 @@ void stack_add_bottom(struct stack *s, char c)
s->crates[s->count - 1] = c;
}

char stack_peek(s)
struct stack *s;
char stack_peek(struct stack *s)
{
if (s->count == 0)
{
Expand All @@ -190,8 +185,7 @@ void stack_push(struct stack *s, char c)
s->crates[0] = c;
}

char stack_pop(s)
struct stack *s;
char stack_pop(struct stack *s)
{
char c;

Expand All @@ -208,9 +202,7 @@ struct stack *s;
return c;
}

void write_stacks(f, s, n) FILE *f;
struct stack *s;
size_t n;
void write_stacks(FILE *f, struct stack *s, size_t n)
{
size_t i, j;

Expand All @@ -226,9 +218,7 @@ size_t n;
}
}

void write_procs(f, p, n) FILE *f;
struct proc *p;
size_t n;
void write_procs(FILE *f, struct proc *p, size_t n)
{
size_t i;

Expand Down
11 changes: 3 additions & 8 deletions src/sol/day6.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ void __attribute__((constructor)) day6_init(void)
fprintf(stderr, "day6 load failed.\n");
}

void day6_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void day6_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
(void) debug_out;

Expand All @@ -31,9 +29,7 @@ FILE *debug_out;
fprintf(out_f, "%d\n", find_first_unique_seq(in_f, 14));
}

int find_first_unique_seq(f, n)
FILE *f;
int n;
int find_first_unique_seq(FILE *f, int n)
{
int i;
char c;
Expand All @@ -59,8 +55,7 @@ int n;
return i;
}

bool has_dups(buf, n) char *buf;
int n;
bool has_dups(char *buf, int n)
{
int i, j;

Expand Down
4 changes: 1 addition & 3 deletions src/sol/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ void __attribute__((constructor)) example_init(void)
fprintf(stderr, "example load failed.\n");
}

void example_sol_func(in_f, out_f, debug_out) FILE *in_f;
FILE *out_f;
FILE *debug_out;
void example_sol_func(FILE *in_f, FILE *out_f, FILE *debug_out)
{
char *line;
size_t nread;
Expand Down

0 comments on commit fc108b8

Please sign in to comment.