At 03:17 PM 10/21/99 -0400, you wrote:
>static void insertion_sort(sort_element *array, int count, int i, ULong id)
>{
> int j;
>
> for (j=count; (j>0) && (id < array[j-1].id); j--) { }
> if (j != count)
> MemMove(&(array[count]), &(array[count-1]),
^^^^^ ^^^^^
are you sure this is supposed to be 'count'?
> (ULong) ((ULong) (count-j) * (ULong) sizeof(sort_element)));
> array[j].id = id;
> array[j].order = i;
> }
>
>In my test case, TOTAL is 38. On the call to this routine where COUNT = 33,
>J is found to be 27, and the MemMove dies with the error message:
>
>Since J is 27, it's trying to move the contents of slots 27 though
>32 into slots 28 through 33. All those casts to ULong are in there because I
>was trying to figure out what the problem could be, and ULong is what the
>doc says for MemMove.
Actually, it's trying to move the contents of slots 33 through 38 into
slots 32 through 37, which I suspect is off the end of the array.