summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2014-07-01 18:14:02 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2014-07-01 18:14:02 +0000
commitee5613d11197bbf4354c98cbf15f8eeb9f38ff88 (patch)
tree47ab82c145351b84edc00a642e6ed1fdc21ad291 /src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp
parent4fe2f225465f17c37cdbeddc623ad66a816ee7a5 (diff)
downloadVirtualBox-svn-ee5613d11197bbf4354c98cbf15f8eeb9f38ff88.tar.gz
Merged in iprt++ dev branch.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@51770 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp')
-rw-r--r--src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp b/src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp
index c0b5a58ebe1..3e7b77cce73 100644
--- a/src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp
+++ b/src/VBox/Runtime/common/string/RTStrPrintHexBytes.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009-2010 Oracle Corporation
+ * Copyright (C) 2009-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -37,20 +37,23 @@
RTDECL(int) RTStrPrintHexBytes(char *pszBuf, size_t cchBuf, void const *pv, size_t cb, uint32_t fFlags)
{
- AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
+ AssertReturn(!(fFlags & ~RTSTRPRINTHEXBYTES_F_UPPER), VERR_INVALID_PARAMETER);
AssertPtrReturn(pszBuf, VERR_INVALID_POINTER);
AssertReturn(cb * 2 >= cb, VERR_BUFFER_OVERFLOW);
AssertReturn(cchBuf >= cb * 2 + 1, VERR_BUFFER_OVERFLOW);
if (cb)
AssertPtrReturn(pv, VERR_INVALID_POINTER);
+ static char const s_szHexDigitsLower[17] = "0123456789abcdef";
+ static char const s_szHexDigitsUpper[17] = "0123456789ABCDEF";
+ const char *pszHexDigits = !(fFlags & RTSTRPRINTHEXBYTES_F_UPPER) ? s_szHexDigitsLower : s_szHexDigitsUpper;
+
uint8_t const *pb = (uint8_t const *)pv;
while (cb-- > 0)
{
- static char const s_szHexDigits[17] = "0123456789abcdef";
uint8_t b = *pb++;
- *pszBuf++ = s_szHexDigits[b >> 4];
- *pszBuf++ = s_szHexDigits[b & 0xf];
+ *pszBuf++ = pszHexDigits[b >> 4];
+ *pszBuf++ = pszHexDigits[b & 0xf];
}
*pszBuf = '\0';
return VINF_SUCCESS;