Does the Palm enforce pointers to be on even boundaries? The reason I ask is
that on a project I'm developing and testing for an original Palm Pilot (OS
2.0), I've been getting consistent errors in a routine I wrote to suffix a
list of character pointers to a memory block containing a set of strings
[for use in passing to the LstSetListChoices]. After much work, I found that
when the suffixed list start point was on odd byte boundary, an address
exception would be generated. If not, then everyhing was fine. Is this a
known Palm issue? I've certainly never heard it anywhere.
Below is the routine. It takes a pointer to the memory block pointer, and
the number of strings that are in the in memory block:
char **StrSuffixPtrs(char **s, int lineCount)
{
int lineCtr;
char **pList, *p;
int origSize = MemPtrSize(*s);
int newSize;
// Resize the memory block to make room for the list of pointers
newSize = origSize + (lineCount+1) * sizeof(char *);
MemPtrResize(*s, newSize);
UInt32 uList = ((UInt32) *s + origSize);
uList += uList % 2; // Make sure pointer will be on an even boundary
pList = (char **) uList;
// pList = (char **) ((UInt32) *s + origSize); // When this line is
enabled, and pList is on an odd byte, problems will occur
p = *s;
// Loop through setting up pointers to each string
for (lineCtr=0; lineCtr<lineCount; lineCtr++)
{
pList[lineCtr] = p; // Failure here, when pList is on an odd byte
p += StrLen(p)+1;
}
// Return a pointer to the pointer list
return pList;
}
Thanks for any help.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/