I've spent hours trying to figure this one out, but
I'm lost.

When I try to query the same record in my database
more than once I get an error of type 'free handle'
when I try to lock the handle obtained by
DmQueryRecord() (comment 2 in the code below).
I do a DmQueryRecord of the same database in two
different forms, and this happens even if I query the
record in different forms - e.g if I query the record
with the index '1' in form A then I can't query the
same record '1' in form B without this error, and the
other way around.

But the odd thing is it only happens if I do a
MemHandleFree() of the handle: if I comment that line
it works, but then I get two memory leaks error when I
close my app, exactly where the MemHandleFree() should
be.

No global variables are involved which could interfere
with one another.
If anyone has any ideas or suggestions as to why this
is happening I'd be much obliged.

Michel.P


//----------------------------------------------------
void InitTable(FormPtr frm)
{
  UInt16 row, recIndex;
  UInt32 recId;
  Err err;
  MemHandle memH;
  Client *c;

  tbl = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm,
TblViewClients));
  
  for(row=0; row<TBL_ROWS; ++row)
  {
                if(row < dbRecords)
                {
                  memH = DmQueryRecord(clientDb, row);
                  
                  //1 THIS CHECK ALWAYS PASSES...
                  if(!memH)
                    FrmCustomAlert(AltCustomInfo, "Couldn't query
record in clientDb", "", "");

                  //2 ...YET ON THE FOLLOWING LINE IT
COMPLAINS ABOUT 'memH' BEING A 'free handle' WHEN I
TRY TO LOCK IT
                  c = (Client*)MemHandleLock(memH);

                  recId = c->recId;
                  
      TblSetItemStyle(tbl, row, 0, customTableItem);
      TblSetRowUsable(tbl, row, true);
      
      err = DmFindRecordByID(g_db, recId, &recIndex);
      if(err == dmErrUniqueIDNotFound)
                    FrmCustomAlert(AltCustomInfo, "Couldn't find
client in addressDB", "", "");
                  
      TblSetRowID(tbl, row, recIndex);
      MemPtrUnlock(c);
      
      //3 IF THIS LINE IS UNCOMMENTED "IT WORKS", BUT
THEN I GET MEMORY LEAKS
      //MemHandleFree(memH);
    }
    else
      TblSetRowUsable(tbl, row, false);
  }
  
  TblSetColumnUsable(tbl, 0, true);
  TblSetCustomDrawProcedure(tbl, 0, CustomDrawClient);
}
//----------------------------------------------------

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to