From 76e03ea9b71186cf6a67d801590b12c531a1e78a Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sat, 28 Jun 2014 22:55:16 -0500 Subject: Move assert_sorted helper somewhere more public --- bench.c | 10 ---------- sorters.c | 13 +++++++++++++ sorters.h | 2 ++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bench.c b/bench.c index 19f7204..65bb99c 100644 --- a/bench.c +++ b/bench.c @@ -37,16 +37,6 @@ static inline unsigned long timediff_ms(struct timespec *start, struct timespec return 1000 * (stop->tv_sec - start->tv_sec) + (stop->tv_nsec - start->tv_nsec) / 1000000; } -static inline void assert_sorted(int *buffer, size_t size) -{ - if (!size) return; - int prev = buffer[0]; - for (size_t i = 1; i < size; i++) { - if (prev > buffer[i]) abort(); - prev = buffer[i]; - } -} - int main() { struct timespec start, stop; diff --git a/sorters.c b/sorters.c index 99e000e..8db94e0 100644 --- a/sorters.c +++ b/sorters.c @@ -1,3 +1,6 @@ +#include +#include + #include "sorters.h" const struct sorter sorters[] = { @@ -8,3 +11,13 @@ const struct sorter sorters[] = { { .name = "wikisort", .func = wikisort }, { 0 } }; + +void assert_sorted(int *buffer, size_t size) +{ + if (!size) return; + int prev = buffer[0]; + for (size_t i = 1; i < size; i++) { + if (prev > buffer[i]) abort(); + prev = buffer[i]; + } +} diff --git a/sorters.h b/sorters.h index b683e91..d451813 100644 --- a/sorters.h +++ b/sorters.h @@ -1,5 +1,7 @@ #include +void assert_sorted(int *buffer, size_t size); + typedef int (*cmpfun)(const void *, const void *); typedef void (*sorter)(void *, size_t, size_t, cmpfun); -- cgit v1.2.3