In case this message is already posted, I'm sorry but I just got the message
 from the postmaster of palmos.com that there was a delivery error...
Dyk

Hi!
I have a memory leak in my application and don't know how to fix it.
I'm filling a table with the TblSetLoadDataProcedure and I think
that that's the problem. The CusomLoadProcedure called 
ListformGetRecordField in my program returns a unlocked handle (*textHP)
that should be freed by the user, but I can't free it... :-(

The problem is, that the handle doesn't contain a database record but is
a concatenation of several fields of one record (this is done in 
GetVeranstaltungInfoString). 
So my table has for example 4 rows and I am getting four memory leaks when
I exit my app. Since I've been looking for any missing MemHandleUnlock, I
think that this memory leak exists since I can't free this textHP Handle.
I looked into the log-file of POSE and the chunks with the memory leaks
contain the information of one row in my table... 

Does anybody have an idea how I could free this memory or whether a memory
leak can't happen just because some memory couldn't bee freed?

I also tried to create an array of pointers to these Handles, but
unfortunately you have to return an unlocked handle from this
CustomLoadprocedure..

ANY help??

MAny thanks,

Dyk

TblSetLoadDataProcedure (table, 1, ListFormGetRecordField);


The ListFormGetRecordField is listed below:

Err ListFormGetRecordField(MemPtr table, Int16 row, Int16 column,
  Boolean editable, MemHandle *textHP, Int16 * textOffset, Int16 *  
  textAllocSize,FieldPtr fld)
{
 UInt16 recordNum, veranstaltungInfoLength, veranstaltungInfoWidth;
 char                   *txtP; 
 char                   *veranstaltungInfo= NULL;
 FieldAttrType  attr;
 MemHandle              recordH, txtH; 
 Veranstaltung  record;
 Veranstaltung  *recordP;
 PackedVeranstaltung *packedRecordP;
 Err err;
 char text[10];

  recordNum = TblGetRowID(table, row);
                
  recordH = DmQueryRecord(gVeranstaltungDB, recordNum);
  ErrFatalDisplayIf ((! recordH), "Record konnte nicht gefunden werden!");
  packedRecordP = (PackedVeranstaltung *) MemHandleLock(recordH);
      
  UnpackVeranstaltung(&record, packedRecordP);
  recordP = &record;

  // Create the text for one table line
  GetVeranstaltungInfoString(recordP,&veranstaltungInfo,                    
  &veranstaltungInfoLength, &veranstaltungInfoWidth, textHP);

  *textOffset =  0;
  *textAllocSize = veranstaltungInfoLength; 

  MemHandleUnlock(recordH);
  MemHandleUnlock(*textHP);
  
  return 0;
}

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


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

Reply via email to