I get an error message indicating that I am reading from an unlocked chunk of memory. The memory chunk in question (trough pointer variable 'value') is however not unlocked by me, and I can't really figure out if it does get unlocked by itself somehow, or if there is something else wrong. I am assuming that it is the variable 'value' that is the problem since I am writing to 'p'. But of course 'p' is also locked by me and not unlocked.
The errormessage below is presented when executing row no: 30 DmWrite(p, 0, (UInt32*)StrAToI(value), sizeof(UInt32)); Grateful for any ideas? - Veronica Loell Error message: --------------- pavotid palm (unknown version) just read from memory location 0x00002714, which is in an unlocked chunk of memory. An "unlocked chunk of memory" is one that has been allocated with MemHandleNew but that has not been locked with MemHandleLock. Such an access usually means that an application allocated a buffer with MemHandleNew, locked it with MemHandleLock, unlocked it with MemHandleUnlock, and then used the pointer that was returned by MemHandleLock. --------------- 1Err parseEss( Int16 start, Int16 end, Char *str ) 2{ 3 UInt16 ix,s1,s2,size; 4 UInt32 snr; 5 Char *value,*v2, *strK, *t1,*t2; 6 Err error; 7 MemHandle h, tempH,tempH2; 8 MemPtr p; 9 ix = DmNumRecords(gtblEssar); 10 HostTraceOutputTL(appErrorClass, "*fcall*xmlFunctions.c:parseEss(start=%hd,end=%hd, str=%s)",start,end,str); 11 h = DmNewRecord(gtblEssar, &ix, sizeof(ppavotidRecEssarType)); 12 if (h) { 13 p = MemHandleLock(h); 14 15 t1 = (Char*)"<s>"; 16 t2 = (Char*)"</s>"; 17 s1 = (UInt16)(StrStr(str, t1 )- str + StrLen(t1)); 18 s2 = (UInt16)(StrStr((str+s1), t2 )- str - 1); 19 size =(UInt16)(s2-s1+2); 20 HostTraceOutputTL(appErrorClass, "ppavotidGetInfo:s1=%hu, s2=%hu, size=%hu",s1,s2,size); 21 tempH = MemHandleNew(sizeof(Char)*(size+1)); 22 if (tempH){ 23 value = (Char*)MemHandleLock(tempH); 24 if (size>0) 25 { 26 value = StrNCopy(value, (str+s1), size); 27 value[size-1] = chrNull; 28 snr = (UInt32)StrAToI(value); 29 HostTraceOutputTL(appErrorClass, "<s>=%lu", snr); 30 DmWrite(p, 0, (UInt32*)StrAToI(value), sizeof(UInt32)); 31 HostTraceOutputTL(appErrorClass, "skrivit till post"); 32 MemHandleFree(tempH); 33 } 34 } .. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/