> I am encountering a problem while using a DmQuickSort, which produces a 
> "DataMgr.c Line 6550 Index out of range" error. The sort is doing nothing
> more than a "StrCompare(&r1->fieldX,&r2->fieldX) where r1 and r2 are the
> two pointers passed in to the comparison routine. The observations are as
> follows:
>
> If I load 16368 records, and go to the application and perform a sort,
> everything is fine. If I now add 22 more records, so I'm up to 16390 (and
> past a magic? 16384 barrier), now when I try to sort I get the crash
> halfway through the sort (I know from the time elapsed that the crash is
> not occuring when the sort finishes and the program goes on to do
> something else).

Here's some things I'd think about:

1) When you call DmQuickSort, does your comparison routine get called?  How
many times?  (If it isn't called any times, then the problem could be the
code at the beginning of DmQuickSort that locks every record).

2) Does DmInsertionSort work OK, or does it also fail.  If it succeeds, it's
probably a logic error in DmQuickSort.

3) If you have a source license, you could copy DmQuickSort, along with any
routines it calls, into your own source files, and then set breakpoints,
etc. to figure out what's going wrong.

4) DmQuickSort isn't doing anything that you couldn't do as quick. You could
always write your own sorting routine.

5) Using PalmDebugger (or possibly even CodeWarrior in assembly mode), you
could look at the stack trace when this happens, and figure out what routine
you're in, what index is being passed, where it's being called from, and
relate that back to the source (again, assuming you have a source license).

6) I can see a bug if there are more than 64K/2 records: In the insertion
sort fallback case of PrvQuickSort, there's code that figures out a middle
index based on a left and right index by adding together the left and right
and then dividing by 2 (can't show the code, sorry).  These indexes are
defined as Int, and therefore, when either of the indexes is more than
32767, there's a sign issue.  Also, when the total is more than 64K, there'd
be a truncation problem.


--
Neil Rhodes
Calliope Enterprises, Inc.
1328 Clock Avenue
Redlands, CA  92374
(909) 793-5995     [EMAIL PROTECTED]      fax: (909) 793-2545

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to