Ok, so i did it! But now i have a problem with MemPtrRecoverHandle it works fine (also the fifth time), but after calling MemHandleSize i got an invalid handle - error!
"Chris Apers" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > You need to lock it only if you want to read/write data from this handle. > > ----- Original Message ----- > From: "Pit" <[EMAIL PROTECTED]> > Newsgroups: palm-dev-forum > To: "Palm Developer Forum" <[EMAIL PROTECTED]> > Sent: Monday, April 19, 2004 4:33 PM > Subject: Re: Problem with MemHandleResize - memErrChunkLocked > > > > Hi, > > > > thank for your fast answer, but i am not sure if i understand you correct. > > > > I thougth i must call MemHandleLock before doing something with the > handle! > > > > Thanks > > Peter > > > > "Chris Apers" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > > news:[EMAIL PROTECTED] > > > You call MemHandleLock before MemHandleResize this is why you have > > > this error. > > > > > > ----- Original Message ----- > > > From: "Pit" <[EMAIL PROTECTED]> > > > Newsgroups: palm-dev-forum > > > To: "Palm Developer Forum" <[EMAIL PROTECTED]> > > > Sent: Monday, April 19, 2004 3:54 PM > > > Subject: Problem with MemHandleResize - memErrChunkLocked > > > > > > > > > > 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/ > > > > > > > > > > > > > > > -- > > For information on using the Palm Developer Forums, or to unsubscribe, > please see http://www.palmos.com/dev/support/forums/ > > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
