Hello
I've declared a TblLoadDataProcedure in a table with 2 columns and 7 rows.
Everytime i exit my application I get a memory leak for every row in the table.
I've found out where the error is, the memory the gets allocated for *handles has to
be freed,
but everytime I try to free it I only free the first element in the array and not all
of it and even this doesnt work without a warning from the emulator.
I even tried to free every single part of it but this gets even worse.
I hope someone can help me.
static Err DrawDetail (void * table, Int16 row, UInt16 column,
Boolean editable, MemHandle *dataH, UInt16 * dataOffset, UInt16 * dataSize,
FieldPtr fld)
{
FieldAttrType attr;
CharPtr p;
VoidHand *handles;
VoidHand CustomerHandles = 0;
Char myString[20];
FldGetAttributes(fld, &attr);
attr.editable = 0;
attr.underlined = 0;
attr.justification = leftAlign;
FldSetAttributes(fld, &attr);
if (!CustomerHandles)
{
ULong numBytes = TblGetNumberOfRows(table) * sizeof(Handle);
CustomerHandles = MemHandleNew(numBytes); //allocate new memory
handles = MemHandleLock(CustomerHandles); //lock the access to
this MemSet(handles, numBytes, 0); //get a
memory heap of size 'numBytes' at &handles and give it the value 0
MemHandleUnlock(CustomerHandles); //free
}
handles = MemHandleLock(CustomerHandles);
if (!handles[row])
{
SysStringByIndex( catName, row /* index */, myString, sizeof(myString)
);
handles[row] = MemHandleNew(StrLen(myString)+1);
p = MemHandleLock(handles[row]);
StrCopy(p, myString);
MemHandleUnlock(handles[row]);
}
*dataH = handles[row];
*dataSize = MemHandleSize(*dataH);
*dataOffset = 0;
MemHandleUnlock(CustomerHandles);
MemHandleFree (CustomerHandles);
return 0;
}
______________________________________________________________________________
Die Besten ihrer Klasse! WEB.DE FreeMail (1,7) und WEB.DE Club (1,9) -
bei der Stiftung Warentest - ein Doppelsieg! http://f.web.de/?mc=021184
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/