At 11:53 PM 5/31/2005, you wrote:
Hi Ben,
Thank you for your suggestion but I am unclear as to how I would implement
such a stratigy. Would you be able to direct me to an example? Would it
look something like this?
if (addToList)
{
UInt32 len = StrLen(packBuffer);
MemHandle packH = MemHandleNew(len + 1);
gPackList[indexLst] = (Char*)MemHandleLock(packH);
MemMove(gPackList[indexLst], packBuffer, len + 1);
indexLst++;
MemHandleUnlock(packH);
packH = 0;
}
No. The problem is this line:
gPackList[indexLst] = (Char*)MemHandleLock(packH);
You store the pointer you get from MemHandleLock in this gPackList
array. This array shouldn't be an array of pointers, but should be an
array of MemHandles. Store the MemHandle value, and later when the array
value is used, lock and unlock the handle there. You can still lock, copy,
and unlock in your loop, but you can't keep around a pointer you get from
MemHandleLock after you've called MemHandleUnlock, since that invalidates
the pointer value.
-- Ben Combee, Senior Software Engineer, palmOne, Inc.
"Combee on Palm OS" weblog: http://palmos.combee.net/
Developer Forum Archives: http://news.palmos.com/read/all_forums/
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/