Changeset 51770 in vbox for trunk/src/VBox/Runtime/common/err/errinfo.cpp
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/bird/hardenedwindows (added) merged: 92692-94610
- Property svn:mergeinfo changed
-
trunk/src/VBox
- Property svn:mergeinfo changed
/branches/bird/hardenedwindows/src/VBox (added) merged: 92692-94610
- Property svn:mergeinfo changed
-
trunk/src/VBox/Runtime/common/err/errinfo.cpp
r44529 r51770 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Error Info .3 * IPRT - Error Info, Setters. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2010-201 2Oracle Corporation7 * Copyright (C) 2010-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 33 34 34 #include <iprt/assert.h> 35 #include <iprt/mem.h>36 35 #include <iprt/string.h> 37 36 38 37 39 40 RTDECL(PRTERRINFO) RTErrInfoAlloc(size_t cbMsg) 41 { 42 PRTERRINFO pErrInfo; 43 RTErrInfoAllocEx(cbMsg, &pErrInfo); 44 return pErrInfo; 45 } 46 47 48 RTDECL(int) RTErrInfoAllocEx(size_t cbMsg, PRTERRINFO *ppErrInfo) 49 { 50 if (cbMsg == 0) 51 cbMsg = _4K; 52 else 53 cbMsg = RT_ALIGN_Z(cbMsg, 256); 54 55 PRTERRINFO pErrInfo; 56 *ppErrInfo = pErrInfo = (PRTERRINFO)RTMemTmpAlloc(sizeof(*pErrInfo) + cbMsg); 57 if (RT_UNLIKELY(!pErrInfo)) 58 return VERR_NO_TMP_MEMORY; 59 60 RTErrInfoInit(pErrInfo, (char *)(pErrInfo + 1), cbMsg); 61 pErrInfo->fFlags = RTERRINFO_FLAGS_T_ALLOC | RTERRINFO_FLAGS_MAGIC; 62 return VINF_SUCCESS; 63 } 64 65 66 RTDECL(void) RTErrInfoFree(PRTERRINFO pErrInfo) 67 { 68 RTMemTmpFree(pErrInfo); 69 } 70 71 72 RTDECL(int) RTErrInfoSet(PRTERRINFO pErrInfo, int rc, const char *pszMsg) 38 RTDECL(int) RTErrInfoSet(PRTERRINFO pErrInfo, int rc, const char *pszMsg) 73 39 { 74 40 if (pErrInfo) … … 85 51 86 52 87 RTDECL(int) 53 RTDECL(int) RTErrInfoSetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...) 88 54 { 89 55 va_list va; … … 95 61 96 62 97 RTDECL(int) 63 RTDECL(int) RTErrInfoSetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va) 98 64 { 99 65 if (pErrInfo) … … 109 75 } 110 76 77 78 RTDECL(int) RTErrInfoAdd(PRTERRINFO pErrInfo, int rc, const char *pszMsg) 79 { 80 if (pErrInfo) 81 { 82 AssertPtr(pErrInfo); 83 if (pErrInfo->fFlags & RTERRINFO_FLAGS_SET) 84 RTStrCat(pErrInfo->pszMsg, pErrInfo->cbMsg, pszMsg); 85 else 86 { 87 while (*pszMsg == ' ') 88 pszMsg++; 89 return RTErrInfoSet(pErrInfo, rc, pszMsg); 90 } 91 } 92 return rc; 93 } 94 95 96 RTDECL(int) RTErrInfoAddF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...) 97 { 98 va_list va; 99 va_start(va, pszFormat); 100 RTErrInfoAddV(pErrInfo, rc, pszFormat, va); 101 va_end(va); 102 return rc; 103 } 104 105 106 RTDECL(int) RTErrInfoAddV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va) 107 { 108 if (pErrInfo) 109 { 110 AssertPtr(pErrInfo); 111 Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC); 112 if (pErrInfo->fFlags & RTERRINFO_FLAGS_SET) 113 { 114 char *pszOut = (char *)memchr(pErrInfo->pszMsg, '\0', pErrInfo->cbMsg - 2); 115 if (pszOut) 116 RTStrPrintfV(pszOut, &pErrInfo->pszMsg[pErrInfo->cbMsg] - pszOut, pszFormat, va); 117 } 118 else 119 { 120 while (*pszFormat == ' ') 121 pszFormat++; 122 return RTErrInfoSetV(pErrInfo, rc, pszFormat, va); 123 } 124 } 125 return rc; 126 } 127
Note:
See TracChangeset
for help on using the changeset viewer.