# HG changeset patch # User Thinker K.F. Li # Date 1221406857 -28800 # Node ID 76ba6fd61c7dd53b4eecf197d2628bb3bdbdbf12 # Parent 5df7403b6fbc1b391017e6e174e897cc5b7ab4b5 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]. diff -r 5df7403b6fbc -r 76ba6fd61c7d src/redraw_man.c --- 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; } }