Hi folks,
im having troubles with the MemHandleResize-function. I use this function in
the following code:
When i call this function 4 times: everthing is OK!
When i call it the fifth time, i get an memErrChunkLocked-error.
I dont know why this happens, and i m getting more and more frustrated. I
hope there is anybody, who
can point me to the problem and hopefully to the solution.
Best Regards
Peter
static void SaveIT (char* it) {
Err error;
MemHandle itHandle;
MemHandle itemHandle;
UInt16 oldSize;
int position;
if (myAppPrefs.it== NULL) {
itHandle= MemHandleNew (sizeof (char*));
myAppPrefs.it= MemHandleLock (itHandle);
itemHandle = MemHandleNew (StrLen (it) + 1);
myAppPrefs.it[0] = MemHandleLock (itemHandle);
StrCopy (myAppPrefs.it[0], it);
MemHandleUnlock (itemHandle);
MemHandleUnlock (itHandle);
}
else {
itHandle= MemPtrRecoverHandle (myAppPrefs.it);
oldSize = MemHandleSize (itHandle);
position = oldSize / sizeof (char*);
MemHandleLock (itHandle);
error = MemHandleResize (itHandle, oldSize + sizeof (char*));
if (error == memErrChunkLocked) {
PrintToField ("memErrChunkLocked");
}
itemHandle = MemHandleNew (StrLen (it) + 1);
myAppPrefs.it[position] = MemHandleLock (itemHandle);
StrCopy (myAppPrefs.it[position], it);
MemHandleUnlock (itemHandle);
MemHandleUnlock (itHandle);
}
}
The used struct, hast the following design
typedef struct {
int number;
char** nothing;
char** it;
} AppPrefs;
AppPrefs myAppPrefs = {-1, NULL, NULL}; // Initialization
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/