I've created a subroutine to pad a string on the left with blanks. The 
question is- since the handle padH is created in the function and passed 
back to the calling routine, how do I free it?  Is it better to have it as a 
global variable or do I create it in the calling function and free it there 
also?  How do others handle this situation.
Thanks in advance.
Jim Haines

MemHandle strPadLeft(char *str, UInt16 maxLen)
{
char *padStr;
UInt16 padLen,i;
MemHandle padH;
padH=MemHandleNew(80);
padStr=MemHandleLock(padH);
padLen=maxLen-StrLen(str);
StrCopy(padStr," ");
for(i=1;i<(2*padLen);i++)
     StrCat(padStr," ");
StrCat(padStr,str);
MemHandleUnlock(padH);
return padH;
}
Jim Haines 

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

Reply via email to