VirtualBox

Changeset 21404 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jul 8, 2009 3:19:42 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49780
Message:

IPRT, Main: make ministring throw std::bad_alloc on allocation failure; remove isEmpty() and isNull(), change Main code to using length() instead; second try

File:
1 edited

Legend:

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

    r21394 r21404  
    3535#include <iprt/string.h>
    3636
     37#include <new>
     38
    3739/**
    3840 *  "ministring" is a small C++ string class that does not depend on anything
     
    125127        {
    126128            m_psz = (char*)RTMemRealloc(m_psz, cb);
     129#ifdef RT_EXCEPTIONS_ENABLED
     130            if (!m_psz)
     131                throw std::bad_alloc();
     132#endif
    127133            m_cbAllocated = cb;
    128134        }
     
    255261    {
    256262        return length() == 0;
    257     }
    258 
    259     /**
    260      * Returns true if no memory is currently allocated.
    261      * @return
    262      */
    263     bool isNull() const
    264     {
    265         return m_psz == NULL;
    266263    }
    267264
     
    349346            m_cbAllocated = m_cbLength + 1;
    350347            m_psz = (char*)RTMemAlloc(m_cbAllocated);
     348#ifdef RT_EXCEPTIONS_ENABLED
     349            if (!m_psz)
     350                throw std::bad_alloc();
     351#endif
    351352            memcpy(m_psz, s.m_psz, m_cbAllocated);      // include 0 terminator
    352353        }
     
    374375            m_cbAllocated = m_cbLength + 1;
    375376            m_psz = (char*)RTMemAlloc(m_cbAllocated);
     377#ifdef RT_EXCEPTIONS_ENABLED
     378            if (!m_psz)
     379                throw std::bad_alloc();
     380#endif
    376381            memcpy(m_psz, pcsz, m_cbAllocated);      // include 0 terminator
    377382        }
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