[EMAIL PROTECTED] wrote:
Once you allocate the memory you then have to make sure that all of your reads/writes stay within the bounds of that allocated memory. Let's suppose that your structure contains nothing but the following:I have done the MemPtrNew function: ComDB *myData = (ComDB*) MemPtrNew (sizeof(ComDB)); StrCopy(myData->com1, "test"); then...code to save the records *snip* MemPtrFree(myData);
When I run the program on POSE, the following message pops up.
"MyProgram just read from memory location 0x000392E2 which is a in Memory Mgr data stuctures.
These data structures include things like the headers preceding each block in heap, as well as the heap header itself. Such an access usually means that an application allocated a buffer (possibly with MemPtrNew) that wasn't large enough for its purpose. When the application then tries to write data to the buffer, it writes off the end of the buffer, accessing the start of the buffer following it in memory. "
Then i click continue and i see that the data has been saved on myAlert. I guess I didnt have an error. But is this message warning me of an error? or is it only informational?
Char com1[4];
When allocating the structure, you have only set aside enough room for 4 bytes. The subsequent StrCopy command will copy 5 bytes (4 characters and a NULL at the end) to the structure, so it has then just written 4 characters to myData->com1 (OK), but it also wrote the trailing NULL outside of the structure (bad). This will give you the error message, and it may or may not crash the device.
Check to make sure that all your reads/writes stay within the bounds.
Bob.
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
