VirtualBox

Changeset 84000 in vbox


Ignore:
Timestamp:
Apr 27, 2020 11:54:11 AM (5 years ago)
Author:
vboxsync
Message:

IPRT/xml: Simplified EIPRTFailure::EIPRTFailure, avoiding two heap allocations and letting the formatter deal with resolving status codes to strings.

File:
1 edited

Legend:

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

    r82968 r84000  
    147147}
    148148
    149 EIPRTFailure::EIPRTFailure(int aRC, const char *pcszContext, ...)
    150     : RuntimeError(NULL),
    151       mRC(aRC)
    152 {
    153     char *pszContext2;
    154     va_list args;
    155     va_start(args, pcszContext);
    156     RTStrAPrintfV(&pszContext2, pcszContext, args);
    157     va_end(args);
    158     char *newMsg;
    159     RTStrAPrintf(&newMsg, "%s: %d (%s)", pszContext2, aRC, RTErrGetShort(aRC));
    160     setWhat(newMsg);
    161     RTStrFree(newMsg);
    162     RTStrFree(pszContext2);
     149EIPRTFailure::EIPRTFailure(int aRC, const char *pszContextFmt, ...)
     150    : RuntimeError(NULL)
     151    , mRC(aRC)
     152{
     153    va_list va;
     154    va_start(va, pszContextFmt);
     155    m_strMsg.printfVNoThrow(pszContextFmt, va);
     156    va_end(va);
     157    m_strMsg.appendPrintfNoThrow(" %Rrc (%Rrs)", aRC, aRC);
    163158}
    164159
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