I use CW8 and Sybase Ultralite to develop a Palm application. I didn't
define any Palm database in my program.
I put a table in form and define two "textTableItem" style of column in the
table. The function setCellMemHandle is the textTableItem's call back
function.
TblSetLoadDataProcedure(table,1,(TableLoadDataFuncPtr)setCellMemHandle);
I put following code in the Function setCellMemhandle:
Err setCellMemHandle (void * table, Int16 row, Int16 column, Boolean
editable, MemHandle *textHP, UInt16 * textOffset, UInt16 * textAllocSize,
FieldPtr fld)
{
MemHandle memH;
//Check if tblGetItemPtr is NULL
//if is NULL: There's no memory allocated for the cell
//if not NULL: a chunk of memory has been apply for the cell and save
the Handle in ItemPtr.
if ((memH = (MemHandle)TblGetItemPtr((TablePtr)table,row,column)) !=
NULL)
{
//combind fld with the memory chuck
FldSetTextHandle(fld,memH);
}
else
{
//apply a chuck of memory for fld and save the handle into ItemPtr.
memH = MemHandleNew((column == 1)?300:10);
FldSetTextHandle(fld,memH);
TblSetItemPtr((TablePtr)table,row,column,memH);
}
return(0);
}
When the program is run, the first table row has no problem, The POSE
crashed when it set the second item in the second table row. It popup
following message:
----------------------------------------------------------------------------
-----------------------
tabletry just read from memory location 0x0002CA6 which in Memory Manager
data structures.
There data structures include things like the headers preceding, each block
in a heap as well as the heap header itself. Such an access usually means
that an application allocated a b uffer [possibly with MemPtrNew) that
wasn't large enough for its purpose. When the application then tries to
wirte data to the buffer. it writes off the end of the buffer. accessing the
start of the buffer following it in memory.
----------------------------------------------------------------------------
-----------------------
If I don't define the call back function "TblSetLoadDataProcedure". Just put
that code into the tblSelectEvent processing function. there would be not
any problem.
What I like to know is: Can I apply a chuck of memory for each textTableItem
cell and save the handle into the ItemPtr in that way. If not, How can I do
it?
Any body can help me for this?
Many thanks.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/