As far I remember, this is almost exact replication from PalmOS reference guide.
It really looks safe, but it means that you relocate memory all the time, that might result in heap fragmentation. Wouldn't it be better to free old handle before getting the new one, given that you don't use its content ? Michael -----Original Message----- From: Brian Smith [mailto:[EMAIL PROTECTED]] Sent: Monday, 26 November 2001 2:44 PM To: Palm Developer Forum Subject: RE: Editing Fields On Mon, 26 Nov 2001, Michael Glickman wrote: > You need MemHandleNew(11) having an extra byte for trailing zero. Maybe, maybe not. Better safe than sorry, though. After looking at the code myself it looks like half of it is pretty unnecessary... and unsafe. You don't have the certainty that any existing buffer for the field is going to hold the new text going in. The same thing is better acomplished with the following code (newhand is just another VoidHand). frmP = FrmGetActiveForm(); fldIndex = FrmGetObjectIndex(frmP, fieldname); fld = FrmGetObjectPtr(frmP, fldIndex); oldhand = FldGetTextHandle(fld); newhand = MemHandleNew(11); fldptr = MemHandleLock(newhand); StrIToA(fldptr, newtime); MemPtrUnlock(fldptr); FldSetTextHandle(fld, newhand); FldDrawField(fld); if (oldhand) MemHandleFree(oldhand); ---------------------------------------------------------------------- Brian Smith // [EMAIL PROTECTED] // http://www.arthurian.nu/ Software Developer // Gamer // Webmaster // System Administrator Echelon Teasers: NSA CIA FBI Mossad MI5 Cocaine Cuba Revolution Espionage -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
