VirtualBox

Ignore:
Timestamp:
Jun 21, 2010 7:49:28 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62876
Message:

iprt/cpp/ministring.h: Added a append variant taking a 'const char *' argument to avoid the unnecessary duplication of constant strings. (tstUtf8.cpp: Dropped some of the lisping.)

File:
1 edited

Legend:

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

    r28800 r30318  
    5050        memcpy(m_psz + lenThis, that.m_psz, lenThat);
    5151        m_psz[lenThis + lenThat] = '\0';
     52        m_cbLength = cbBoth - 1;
     53    }
     54    return *this;
     55}
     56
     57MiniString &MiniString::append(const char *pszThat)
     58{
     59    size_t cchThat = strlen(pszThat);
     60    if (cchThat)
     61    {
     62        size_t cchThis = length();
     63        size_t cbBoth = cchThis + cchThat + 1;
     64
     65        reserve(cbBoth);
     66            // calls realloc(cbBoth) and sets m_cbAllocated; may throw bad_alloc.
     67#ifndef RT_EXCEPTIONS_ENABLED
     68        AssertRelease(capacity() >= cbBoth);
     69#endif
     70
     71        memcpy(m_psz + cchThis, pszThat, cchThat);
     72        m_psz[cbBoth - 1] = '\0';
    5273        m_cbLength = cbBoth - 1;
    5374    }
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