VirtualBox

Changeset 85288 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Jul 13, 2020 12:19:47 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139265
Message:

Main: Adding two Bstr::assignEx variants that returns HRESULT instead of throwing exceptions. bugref:9790

File:
1 edited

Legend:

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

    r84339 r85288  
    620620    {
    621621        m_bstr = ::SysAllocString(a_bstrSrc);
    622         if (!m_bstr)
     622        if (RT_LIKELY(m_bstr))
     623        { /* likely */ }
     624        else
    623625            throw std::bad_alloc();
    624626    }
     
    632634    cleanup();
    633635    copyFrom(a_bstrSrc);
     636}
     637
     638
     639HRESULT Bstr::cleanupAndCopyFromEx(const OLECHAR *a_bstrSrc) RT_NOEXCEPT
     640{
     641    cleanup();
     642
     643    if (a_bstrSrc && *a_bstrSrc)
     644    {
     645        m_bstr = ::SysAllocString(a_bstrSrc);
     646        if (RT_LIKELY(m_bstr))
     647        { /* likely */ }
     648        else
     649            return E_OUTOFMEMORY;
     650    }
     651    else
     652        m_bstr = NULL;
     653    return S_OK;
    634654}
    635655
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