From 91fb1b03cc3840ac10f19b734a00c5898506bdb9 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sun, 1 Dec 2024 00:14:56 -0500 Subject: [PATCH] Move int sort function to lib --- c/2024/1/historian_hysteria.c | 8 ++------ c/lib/aoc.h | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/c/2024/1/historian_hysteria.c b/c/2024/1/historian_hysteria.c index b1bdc25..039be4f 100644 --- a/c/2024/1/historian_hysteria.c +++ b/c/2024/1/historian_hysteria.c @@ -4,10 +4,6 @@ #include "../../lib/aoc.h" -int sort(const void *a, const void *b) { - return *(int*) a - *(int*) b; -} - int main() { char *line; @@ -23,8 +19,8 @@ int main() { index++; } - qsort(left, 1000, sizeof(int), sort); - qsort(right, 1000, sizeof(int), sort); + qsort(left, 1000, sizeof(int), aoc_sort_int); + qsort(right, 1000, sizeof(int), aoc_sort_int); int sum = 0; diff --git a/c/lib/aoc.h b/c/lib/aoc.h index f5f3118..8ab52a9 100644 --- a/c/lib/aoc.h +++ b/c/lib/aoc.h @@ -53,3 +53,9 @@ void aoc_free(void) { free(input_buffer); free(read_line_buffer); } + + +int aoc_sort_int(const void *a, const void *b) { + return *(int*) a - *(int*) b; +} +