VirtualBox

Changeset 95956 in vbox


Ignore:
Timestamp:
Jul 29, 2022 8:54:43 PM (2 years ago)
Author:
vboxsync
Message:

Main/glue/string.cpp: Made the code compile w/o exceptions. It is used by VBoxCredPros in the GAs, which in no-CRT mode have exceptions disabled. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/string.cpp

    r93115 r95956  
    4343    HRESULT hrc = printfVNoThrow(pszFormat, va);
    4444    va_end(va);
     45#ifdef RT_EXCEPTIONS_ENABLED
    4546    if (hrc == S_OK)
    4647    { /* likely */ }
    4748    else
    4849        throw std::bad_alloc();
     50#else
     51    Assert(hrc == S_OK); RT_NOREF(hrc);
     52#endif
    4953    return *this;
    5054}
     
    6367{
    6468    HRESULT hrc = printfVNoThrow(pszFormat, va);
     69#ifdef RT_EXCEPTIONS_ENABLED
    6570    if (hrc == S_OK)
    6671    { /* likely */ }
    6772    else
    6873        throw std::bad_alloc();
     74#else
     75    Assert(hrc == S_OK); RT_NOREF(hrc);
     76#endif
    6977    return *this;
    7078}
     
    183191    else /* ASSUME: input is valid Utf-8. Fake out of memory error. */
    184192        AssertLogRelMsgFailed(("%Rrc %.*Rhxs\n", vrc, RTStrNLen(a_pszSrc, a_cchMax), a_pszSrc));
     193#ifdef RT_EXCEPTIONS_ENABLED
    185194    throw std::bad_alloc();
     195#endif
    186196}
    187197
     
    324334{
    325335    HRESULT hrc = joltNoThrow(cwcNew);
     336# ifdef RT_EXCEPTIONS_ENABLED
    326337    if (hrc != S_OK)
    327338        throw std::bad_alloc();
     339# else
     340    Assert(hrc == S_OK); RT_NOREF(hrc);
     341# endif
    328342}
    329343
     
    360374{
    361375    HRESULT hrc = reserveNoThrow(cwcMin, fForce);
     376#ifdef RT_EXCEPTIONS_ENABLED
    362377    if (hrc != S_OK)
    363378        throw std::bad_alloc();
     379#else
     380    Assert(hrc == S_OK); RT_NOREF(hrc);
     381#endif
    364382}
    365383
     
    550568    size_t cwcSrc;
    551569    int rc = RTStrCalcUtf16LenEx(pszSrc, cchSrc, &cwcSrc);
     570#ifdef RT_EXCEPTIONS_ENABLED
    552571    AssertRCStmt(rc, throw std::bad_alloc());
     572#else
     573    AssertRCReturn(rc, *this);
     574#endif
    553575
    554576    size_t cwcOld = length();
     
    559581        PRTUTF16 pwszDst = &m_bstr[cwcOld];
    560582        rc = RTStrToUtf16Ex(pszSrc, cchSrc, &pwszDst, cwcSrc + 1, NULL);
     583#ifdef RT_EXCEPTIONS_ENABLED
    561584        AssertRCStmt(rc, throw std::bad_alloc());
     585#else
     586        AssertRC(rc);
     587#endif
    562588    }
    563589    m_bstr[cwcTotal] = '\0';
     
    593619    HRESULT hrc = appendPrintfVNoThrow(pszFormat, va);
    594620    va_end(va);
     621#ifdef RT_EXCEPTIONS_ENABLED
    595622    if (hrc != S_OK)
    596623        throw std::bad_alloc();
     624#else
     625    Assert(hrc == S_OK); RT_NOREF(hrc);
     626#endif
    597627    return *this;
    598628}
     
    612642{
    613643    HRESULT hrc = appendPrintfVNoThrow(pszFormat, va);
     644#ifdef RT_EXCEPTIONS_ENABLED
    614645    if (hrc != S_OK)
    615646        throw std::bad_alloc();
     647#else
     648    Assert(hrc == S_OK); RT_NOREF(hrc);
     649#endif
    616650    return *this;
    617651}
     
    682716    {
    683717        m_bstr = ::SysAllocString(a_bstrSrc);
     718#ifdef RT_EXCEPTIONS_ENABLED
    684719        if (RT_LIKELY(m_bstr))
    685720        { /* likely */ }
    686721        else
    687722            throw std::bad_alloc();
     723#else
     724        Assert(m_bstr);
     725#endif
    688726    }
    689727    else
     
    733771        memcpy(*pstr, c_str(), cb);
    734772    else
     773#ifdef RT_EXCEPTIONS_ENABLED
    735774        throw std::bad_alloc();
     775#else
     776        AssertFailed();
     777#endif
    736778}
    737779
     
    882924            m_psz = NULL;
    883925
     926#ifdef RT_EXCEPTIONS_ENABLED
    884927            throw std::bad_alloc();
     928#else
     929            AssertFailed();
     930#endif
    885931        }
    886932    }
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