From 82df7c98d4268ff7cdc9bad60fc576201767dfe9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 23:20:46 +0000 Subject: [PATCH] clean up: rename get_order() to merge() and mark static No other function than mergesort_ranges() can use the merge(), so calling it with rather generic name and making it static seems right to me. Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 2 -- src/sort.c | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index ec95e18..dda625f 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -232,8 +232,6 @@ unsigned long int ret_touched(struct range_t r); unsigned long int ret_tc(struct range_t r); unsigned long int ret_tcperc(struct range_t r); void field_selector(char c); -int get_order(struct range_t *__restrict left, struct range_t *__restrict right) - __attribute__ ((nonnull(1, 2))); void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); diff --git a/src/sort.c b/src/sort.c index 480fec5..30a4267 100644 --- a/src/sort.c +++ b/src/sort.c @@ -197,11 +197,9 @@ void field_selector(char c) /*! \brief Perform requested sorting. * \param left The left side of the merge sort. * \param right The right side of the merge sort. - * FIXME: This function should be marked as static. - * FIXME: Really horribly named indirection about which function is in use. * \return Relevant for merge sort decision. */ -int get_order(struct range_t *restrict left, struct range_t *restrict right) +static int merge(struct range_t *restrict left, struct range_t *restrict right) { int i, len, ret; unsigned long int lint, rint; @@ -256,7 +254,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, for (left = 0; left < size; left++) { hold = *(orig + left); for (right = left - 1; 0 <= right; right--) { - if (get_order((orig + right), &hold)) { + if (merge((orig + right), &hold)) { break; } *(orig + right + 1) = *(orig + right); @@ -274,7 +272,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, i = 0; while (left < size / 2 && right < size) { - if (get_order((orig + left), (orig + right))) { + if (merge((orig + left), (orig + right))) { *(temp + i) = *(orig + left); left++; } else {