Tuesday, January 21, 2003, 1:23:13 PM, you wrote:

The problem is you could get an access violation by not using
lstrcpyn vs. lstrcpy.  Suppose src's strlen is greater than the size,
then using lstrcpy will cause an error to occur.  Using lstrcpyn still
could get an access violation, but atleast then we are relying on TB
to send the size of dest which is what it does.

Rob

> You don't need to allocate additional space for the null char. This
> works fine for me:

> static int __inline TBPGetString(PChar src, PChar dest, int size)
> {
>         int     nRetVal=0;

>         if (NULL != src)
>                 nRetVal = lstrlen(src);
>         if ((NULL != dest) && (size > 0))
>         {
>                 if (size > nRetVal)
>                         size = nRetVal;
>                 if (size > 0)
>                 {
>                         lstrcpy(dest, src);
>                         nRetVal = size;
>                 }
>         }
>         return (nRetVal);
> }


________________________________________________
Current version is 1.62 | "Using TBDEV" information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to