VirtualBox

Changeset 78732 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
May 24, 2019 3:28:44 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/string: Implemented RTUtf16CopyEx.

File:
1 copied

Legend:

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

    r78704 r78732  
    11/* $Id$ */
    22/** @file
    3  * IPRT - RTUtf16Copy.
     3 * IPRT - RTUtf16CopyEx.
    44 */
    55
     
    3535
    3636
    37 RTDECL(int) RTUtf16Copy(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc)
     37RTDECL(int) RTUtf16CopyEx(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc, size_t cwcSrcMax)
    3838{
    39     size_t wcwSrc = RTUtf16Len(pwszSrc);
    40     if (RT_LIKELY(wcwSrc < cwcDst))
     39    size_t cwcSrc = RTUtf16NLen(pwszSrc, cwcSrcMax);
     40    if (RT_LIKELY(cwcSrc < cwcDst))
    4141    {
    42         memcpy(pwszDst, pwszSrc, (wcwSrc + 1) * sizeof(RTUTF16));
     42        memcpy(pwszDst, pwszSrc, cwcSrc * sizeof(RTUTF16));
     43        pwszDst[cwcSrc] = '\0';
    4344        return VINF_SUCCESS;
    4445    }
     
    5152    return VERR_BUFFER_OVERFLOW;
    5253}
    53 RT_EXPORT_SYMBOL(RTUtf16Copy);
     54RT_EXPORT_SYMBOL(RTUtf16CopyEx);
    5455
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