// global MemHandle MemHandle h = NULL;
// Append data to whatever is already in handle void WriteDataToHandle(Char *dataInP) { Char *strP; Err err; UInt16 len = StrLen(dataInP); if (!h) { h = MemHandleNew(len+1); if (h) { strP = (Char *)MemHandleLock(h); if (strP) { StrCopy(strP, dataInP); MemHandleUnlock(h); } } } else { err = MemHandleResize(MemHandleSize(h)+(len+1)); if (!err) { strP = (Char *)MemHandleLock(h); if (strP) { // Append data StrCat(strP, dataInP); MemHandleUnlock(h); } } } }
// Read data from handle void ReadDataFromHandle() { Char *strP = NULL; if (h) { strP = (Char *)MemHandleLock(h); if (strP) { DisplayStr(strP); MemHandleUnlock(h); } } }
// Finally free handle MemHandleFree(h);
Regards,
Ger
From: "blaman" <[EMAIL PROTECTED]> Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[EMAIL PROTECTED]> Subject: Re: newbie question: how to read a string from a MemHandle? Date: Thu, 7 Aug 2003 11:30:08 +0200
at first thanx for your reply. However, when i try to access strP my programm crashes telling me it read memory from the memory manager data structures. Any idea what i did wrong? i locked the handle to write it, unlocked it, locked it again by
strP = (Char *)MemHandleLock(h);
accessed strP and it crashed.
"Gearoid Murphy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Char *strP; > > strP = (Char *)MemHandleLock(h); // h is a MemHandle > > > if (strP) > { > // Do stuff with strP > } > > // Make sure to unlock MemHandle > MemHandleUnlock(h);
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/