Mercurial > MadButterfly
diff src/redraw_man.c @ 121:76ba6fd61c7d
More bug of insert sort.
elms[i] is over wrote by elms[i-1]. Save it to a local variable at
start of loop iteration for elms[i].
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 14 Sep 2008 23:40:57 +0800 |
parents | 257a1d314bcd |
children | 4c2d83721bcc |
line wrap: on
line diff
--- a/src/redraw_man.c Sun Sep 14 23:05:30 2008 +0800 +++ b/src/redraw_man.c Sun Sep 14 23:40:57 2008 +0800 @@ -40,15 +40,17 @@ static void _insert_sort(void **elms, int num, int off) { int i, j; unsigned int val; + void *elm_i; for(i = 1; i < num; i++) { - val = *(unsigned int *)(elms[i] + off); + elm_i = elms[i]; + val = *(unsigned int *)(elm_i + off); for(j = i; j > 0; j--) { if(*(unsigned int *)(elms[j - 1] + off) <= val) break; elms[j] = elms[j - 1]; } - elms[j] = elms[i]; + elms[j] = elm_i; } }