From 82a55e7b0758f1b0afa45ac19953a9eb398f3771 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 27 Mar 2020 17:04:08 +0100 Subject: Fixed shit --- src/ft_sort_s_t.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index 31ae237..9cbde8b 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -33,6 +33,19 @@ float return (dist_tab); } +static void + ft_init_st(int32_t *st_o) +{ + int8_t i; + + i = 0; + while (i < FT_TOTAL_SPRT) + { + st_o[i] = i; + i++; + } +} + static void ft_swap_them(int16_t i, float **dist_tab) { @@ -50,10 +63,11 @@ void int32_t tmp; i = -1; + ft_init_st(cl->mlist.st_o); while (++i < FT_TOTAL_SPRT) { - cl->mlist.st_o[i] = i; - if (dist_tab[i][0] < dist_tab[i + 1][0]) + if (i < FT_TOTAL_SPRT && dist_tab[i][0] + && dist_tab[i][0] < dist_tab[i + 1][0]) { tmp = cl->mlist.st_o[i]; cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; -- cgit v1.2.3