On Wed, 07 Jan 2004 06:12:21 -0800, Joe Siebenmann wrote:

> Hi All,
> 
> In my utilities, I have the 'stardard' SetFieldText() function:
> 
> void SetFieldText(FieldPtr fldP, Char * string) {
>       UInt16  size;
>       MemHandle       textH;
>       Char *  textP;
>       
>       size = StrLen((const Char *)string);
>       if ( size > 0 && fldP )
>       {
>               size++;
>               textH = MemHandleNew(size);
>               if ( textH )
>               {
>                       textP = MemHandleLock(textH);
>                       MemMove(textP, string, size);
>                       FldSetTextHandle(fldP, textH);
>                       
>                       MemHandleUnlock(textH);
>               }
>               }
>       }
> }
> Problem is... if I turn on  'MemMgr leaks', on the 4.0 debug ROM, it says
> that, every time it gets used, that there was a memory leak.
> 
> I thought the system was supposed to clean-up the memory for the text
> handle when the app exits.
> 
> Is there something else I need to do? ( to make sure the memory is free'd
> )  Can I 'ignore' the warning? ( it IS cleaning it up )
> 

the system cleans up after you, but still warns you about it and it is
good practice to resolve those memleaks since your app could run out of
dynamic memory during execution time. In your case you have to free the
old text handle which is associated with the field. otherwise it is
getting forgotten,thus the mem leak warnings. the new text handle,
associated with the field, will be freed when the form is getting
destructed.

best regards,

Sebastian 

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

Reply via email to