VirtualBox

Changeset 103252 in vbox


Ignore:
Timestamp:
Feb 7, 2024 2:40:12 PM (15 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161541
Message:

IPRT/string: Added RTStrCopy2() as a convenient function.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r103014 r103252  
    22732273# define RTStrConvertHexBytesEx                         RT_MANGLER(RTStrConvertHexBytesEx)
    22742274# define RTStrCopy                                      RT_MANGLER(RTStrCopy)
     2275# define RTStrCopy2                                     RT_MANGLER(RTStrCopy2)
    22752276# define RTStrCopyEx                                    RT_MANGLER(RTStrCopyEx)
    22762277# define RTStrCopyP                                     RT_MANGLER(RTStrCopyP)
  • trunk/include/iprt/string.h

    r103024 r103252  
    23782378 * String copy with overflow handling.
    23792379 *
     2380 * @return  Pointer to \a pszDst on success, or NULL on failure.
     2381 *
     2382 * @param   pszDst              The destination buffer.
     2383 * @param   cbDst               The size of the destination buffer (in bytes).
     2384 * @param   pszSrc              The source string.  NULL is not OK.
     2385 */
     2386RTDECL(char *) RTStrCopy2(char *pszDst, size_t cbDst, const char *pszSrc);
     2387
     2388/**
     2389 * String copy with overflow handling.
     2390 *
    23802391 * @retval  VINF_SUCCESS on success.
    23812392 * @retval  VERR_BUFFER_OVERFLOW if the destination buffer is too small.  The
  • trunk/src/VBox/Runtime/common/string/RTStrCopy.cpp

    r98103 r103252  
    4545
    4646
    47 RTDECL(int) RTStrCopy(char *pszDst, size_t cbDst, const char *pszSrc)
     47DECLINLINE(int) rtStrCopy(char *pszDst, size_t cbDst, const char *pszSrc)
    4848{
    4949    size_t cchSrc = strlen(pszSrc);
     
    6161    return VERR_BUFFER_OVERFLOW;
    6262}
     63
     64RTDECL(int) RTStrCopy(char *pszDst, size_t cbDst, const char *pszSrc)
     65{
     66    return rtStrCopy(pszDst, cbDst, pszSrc);
     67}
    6368RT_EXPORT_SYMBOL(RTStrCopy);
    6469
     70RTDECL(char *) RTStrCopy2(char *pszDst, size_t cbDst, const char *pszSrc)
     71{
     72    return RT_SUCCESS(rtStrCopy(pszDst, cbDst, pszSrc)) ? pszDst : NULL;
     73}
     74RT_EXPORT_SYMBOL(RTStrCopy2);
     75
Note: See TracChangeset for help on using the changeset viewer.

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