Upon cursory examination of your code it looks like the second position has
the potential to not be called.  I have been caught by this kind of thing
many times, where I lock a handle and the unlock is in a logic block that
might not be called.  I then get an overlocked error.  As for the free
handle, it appears to me that you might be deleting the record that you have
locked the handle for.  So I might not be following your logic correctly . .
. but if this does happen then it could cause a problem.  I have only
encountered the free handle message when I had a function that returned the
handle for a specific record, but the declaration and definition were
VoidHand func(index), rather than static VoidHand func(index).

Hope this helps in some way,
Paul

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Dyk
Corman
Sent: Monday, April 15, 2002 9:27 AM
To: Palm Developer Forum
Subject: Chunk overlocked.. any help ? (not that easy :-)


Hi guys..

yes I did it again.

I overlocked a chunk but can't find the mistake.

The problem is that the error occurs only every 13. time I'm running my
program.
I know that you can only lock a chunk 13 times, but I thought that the OS
woul free all chunks that had been used by an application when this
application
is closed.

So probably I forgot to unlock a chunk somewhere, but I can't find this
chunk (after
having looked for it for about 13 hours)

Is there any possibility to show me the number of locks of a chunk?

Ok, here is another problem, in the following code that should iterate
through my
database I can put MemHandleUnlock(recordH) in the first position (which
doesn't make
any sense, but it works) but I can't put it into the second position. If I
write it there, the emulator
just crashes with the message "Free Handle"

Any help?

Many thanks, Dyk


 for (recordNeuNum = 0; recordNeuNum < numRecordsNeu; recordNeuNum ++)
{
      DmSeekRecordInCategory(gVeranstaltungNeuDB, &recordNeuIndex, 0,
       dmSeekForward, dmAllCategories);

       recordH  = DmQueryRecord (gVeranstaltungNeuDB, recordNeuIndex);
        if (!recordH)
        {
              FrmCustomAlert(MyAlert, "Problem beim Auslesen der neuen DB!",
"", "");
             err = DmGetLastErr();
             break;
        }
        else
        {
                pointer_auf_neue_v= (Veranstaltung_neu *)
MemHandleLock(recordH);
              neueVeranstaltung = * pointer_auf_neue_v;

            / /  ### Position 1 for #######   MemHandleUnlock(recordH);

          // delete all old records.
          TimSecondsToDateTime (TimGetSeconds (), &dateTime);

          todayInt =  ( ((Int32) dateTime.year-1904) << 16) +
               ( ((Int32) dateTime.month) << 8) +
                ((Int32) dateTime.day);

          dateInt =  ( ((Int32) pointer_auf_neue_v->datum_jahr) << 16) +
                  ( ((Int32) pointer_auf_neue_v->datum_monat) << 8) +
                  ((Int32) pointer_auf_neue_v->datum_tag);


          if (todayInt > dateInt)
          {
                   err = DmDeleteRecord(gVeranstaltungNeuDB,
recordNeuIndex);
                   deletedOldRecordsNum ++;
                  // ### Position 2 for ###########
MemHandleUnlock(recordH);
               continue; // -> jump to the next record
             }

           // so now, every record is in the future..

           // do some stuff with this record
           MemHandleUnlock(recordH)
      }

} // next in loop



--
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/

Reply via email to