Hello all,
I use a struct, see below, to store information. But I cannot copy data
to it by using dynamic memory allocation. It's no problem if I use
static memory allocation.
Please see my code snippet below and see what is wrong.
I would really appreciate if someone could help me.
-------------------------------------------------------------------
// Define a struct
typedef struct TransInfo
{
VoidHand user;
VoidHand password;
} TransInfo;
// Declare a struct pointer
TransInfo* currentTransInfo;
VoidHand textHandle;
CharPtr textPtr;
FieldPtr fldptrid;
// Get data from textfield
fldptrid = (FieldPtr) GetObjectPtr(UseridEditField);
textHandle = FldGetTextHandle(fldptrid);
textPtr = (CharPtr)MemHandleLock(textHandle);
// Get handle to a string in the struct
currentTransInfo->user = (VoidHand)MemHandleNew(sizeof(textPtr));
loginPtr = (CharPtr)MemHandleLock(currentTransInfo->user);
// Copy the data from the record to the new memory chunk.
StrCopy(loginPtr, textPtr);
-------------------------------------------------------------------
The last statement, "StrCopy(loginPtr, textPtr);" , generates following
error message when I debug:
------------------------------------------------------------------------------
"AppName" 1.0 has just written directly to memory manager data
structures.
This problem indicates an error in the application...etc.
-----------------------------------------------------------------------------
Can anyone tell me, why is that?
Regards, Anders
--
Anders Larsson
Wip AB http://www.wip.se
Phone: +46 - 455 - 33 98 11 Fax: +46 - 455 - 33 98 98
Mobile: +46 - 708 - 31 91 11
E-mail: [EMAIL PROTECTED]
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/