Hi all,

I am trying to execute some code which points to some text in a field
(inputted by the user).
I call the function below three times in succession.  Now, when I run this
program through the debugger, the first time this function is called, it
goes through without any errors.  When the function is called the second
time, the program breaks and the following error occurs at the starred line:

'memorymgr.c, Line:3706, Invalid handle'

Does anybody know why this might be?  I assume I am not freeing the memory
chunk properly  or something.
Any ideas on how to fix the problem?

Thanks,
Abid


{
        FormPtr         frm;
        FieldPtr        fld;
        UInt16          obj;
        Char            *p;
        MemHandle       h;

        frm = FrmGetFormPtr(formID);
        obj = FrmGetObjectIndex(frm, fieldID);
        fld = (FieldPtr)FrmGetObjectPtr(frm, obj);
        *********** h = FldGetTextHandle(fld); ***************
        p = MemHandleLock(h);
        StrCopy(p, q);


        FldSetTextHandle(fld,h);
        MemHandleUnlock(h);
        MemSet(p, 20, 0);
        MemHandleFree(h);
}


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to