VirtualBox

Ignore:
Timestamp:
Nov 10, 2024 2:26:41 AM (3 months ago)
Author:
vboxsync
Message:

IPRT: Added C++ versions of bzero, memmove, strcmp & strncpy for win.arm64 to use in RuntimeR0 and other nocrt situations. jiraref:VBP-1442

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strncpy.cpp

    r106914 r106917  
    11/* $Id$ */
    22/** @file
    3  * IPRT - CRT Strings, strcpy().
     3 * IPRT - CRT Strings, strncpy().
    44 */
    55
     
    4949 * @param   pszDst      Will contain a copy of pszSrc.
    5050 * @param   pszSrc      Zero terminated string.
     51 * @param   cbDst       Size of the destination buffer.
    5152 */
    5253#ifdef IPRT_NO_CRT
    53 # undef strcpy
    54 char *RT_NOCRT(strcpy)(char *pszDst, const char *pszSrc)
     54# undef strncpy
     55char *RT_NOCRT(strncpy)(char *pszDst, const char *pszSrc, size_t cbDst)
    5556#else
    56 char *strcpy(char *pszDst, const char *pszSrc)
     57char *strncpy(char *pszDst, const char *pszSrc, size_t cbDst)
    5758#endif
    5859{
    59     char * const pszRet = pszDst;
    60     while ((*pszDst = *pszSrc++) != '\0')
    61         pszDst++;
     60    size_t off = 0;
     61    while (off < cbDst)
     62    {
     63        char const ch = *pszSrc;
     64        pszDst[off++] = ch;
     65        if (ch)
     66        { /* likely */ }
     67        else
     68        {
     69            /* (this zeroing is not very efficient) */
     70            while (off < cbDst)
     71                pszDst[off++] = '\0';
     72            break;
     73        }
     74    }
    6275
    63     return pszRet;
     76    return pszDst;
    6477}
    65 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strcpy);
     78RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strncpy);
    6679
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette