VirtualBox

Changeset 21428 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 9, 2009 11:11:11 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49816
Message:

Main: remove ENoMemory exception class, replace with std::bad_alloc() to avoid string allocations after memory allocation failed already

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r21409 r21428  
    168168{
    169169    Data()
    170         : fileName (NULL), handle (NIL_RTFILE), opened (false) {}
    171 
    172     char *fileName;
     170        : handle(NIL_RTFILE), opened(false)
     171    { }
     172
     173    iprt::MiniString strFileName;
    173174    RTFILE handle;
    174175    bool opened : 1;
     
    176177
    177178File::File(Mode aMode, const char *aFileName)
    178     : m (new Data())
    179 {
    180     m->fileName = RTStrDup (aFileName);
    181     if (m->fileName == NULL)
    182         throw ENoMemory();
     179    : m(new Data())
     180{
     181    m->strFileName = aFileName;
    183182
    184183    unsigned flags = 0;
     
    205204}
    206205
    207 File::File (RTFILE aHandle, const char *aFileName /* = NULL */)
    208     : m (new Data())
     206File::File(RTFILE aHandle, const char *aFileName /* = NULL */)
     207    : m(new Data())
    209208{
    210209    if (aHandle == NIL_RTFILE)
     
    214213
    215214    if (aFileName)
    216     {
    217         m->fileName = RTStrDup (aFileName);
    218         if (m->fileName == NULL)
    219             throw ENoMemory();
    220     }
     215        m->strFileName = aFileName;
    221216
    222217    setPos (0);
     
    226221{
    227222    if (m->opened)
    228         RTFileClose (m->handle);
    229 
    230     RTStrFree (m->fileName);
    231 }
    232 
    233 const char *File::uri() const
    234 {
    235     return m->fileName;
     223        RTFileClose(m->handle);
     224}
     225
     226const char* File::uri() const
     227{
     228    return m->strFileName.c_str();
    236229}
    237230
     
    796789    if (!(plibNode = xmlNewNode(NULL,        // namespace
    797790                                (const xmlChar*)pcszElementName)))
    798         throw ENoMemory();
     791        throw std::bad_alloc();
    799792    xmlAddChild(m->plibNode, plibNode);
    800793
     
    823816    xmlNode *plibNode;
    824817    if (!(plibNode = xmlNewText((const xmlChar*)pcszContent)))
    825         throw ENoMemory();
     818        throw std::bad_alloc();
    826819    xmlAddChild(m->plibNode, plibNode);
    827820
     
    10461039    if (!(plibRootNode = xmlNewNode(NULL,        // namespace
    10471040                                    (const xmlChar*)pcszRootElementName)))
    1048         throw ENoMemory();
     1041        throw std::bad_alloc();
    10491042    xmlDocSetRootElement(m->plibDocument, plibRootNode);
    10501043
     
    10671060    m_ctxt = xmlNewParserCtxt();
    10681061    if (m_ctxt == NULL)
    1069         throw ENoMemory();
     1062        throw std::bad_alloc();
    10701063}
    10711064
     
    10901083    {
    10911084        if (!(ctxt = xmlNewParserCtxt()))
    1092             throw xml::ENoMemory();
     1085            throw std::bad_alloc();
    10931086    }
    10941087
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