summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/support/hex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/support/hex.c')
-rw-r--r--src/third_party/wiredtiger/src/support/hex.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/third_party/wiredtiger/src/support/hex.c b/src/third_party/wiredtiger/src/support/hex.c
index eb9f420911a..d42a84154ca 100644
--- a/src/third_party/wiredtiger/src/support/hex.c
+++ b/src/third_party/wiredtiger/src/support/hex.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
@@ -8,7 +8,7 @@
#include "wt_internal.h"
-static const u_char hex[] = "0123456789abcdef";
+const u_char __wt_hex[] = "0123456789abcdef";
/*
* __fill_hex --
@@ -25,8 +25,8 @@ __fill_hex(const uint8_t *src, size_t src_max,
--dest_max;
for (; src_max > 0 && dest_max > 1;
src_max -= 1, dest_max -= 2, ++src) {
- *dest++ = hex[(*src & 0xf0) >> 4];
- *dest++ = hex[*src & 0x0f];
+ *dest++ = __wt_hex[(*src & 0xf0) >> 4];
+ *dest++ = __wt_hex[*src & 0x0f];
}
*dest++ = '\0';
if (lenp != NULL)
@@ -34,6 +34,17 @@ __fill_hex(const uint8_t *src, size_t src_max,
}
/*
+ * __wt_fill_hex --
+ * In-memory conversion of raw bytes to a hexadecimal representation.
+ */
+void
+__wt_fill_hex(const uint8_t *src, size_t src_max,
+ uint8_t *dest, size_t dest_max, size_t *lenp)
+{
+ __fill_hex(src, src_max, dest, dest_max, lenp);
+}
+
+/*
* __wt_raw_to_hex --
* Convert a chunk of data to a nul-terminated printable hex string.
*/
@@ -72,10 +83,6 @@ __wt_raw_to_esc_hex(
*/
WT_RET(__wt_buf_init(session, to, size * 3 + 1));
- /*
- * In the worst case, every character takes up 3 spaces, plus a
- * trailing nul byte.
- */
for (p = from, t = to->mem, i = size; i > 0; --i, ++p)
if (isprint((int)*p)) {
if (*p == '\\')
@@ -83,8 +90,8 @@ __wt_raw_to_esc_hex(
*t++ = *p;
} else {
*t++ = '\\';
- *t++ = hex[(*p & 0xf0) >> 4];
- *t++ = hex[*p & 0x0f];
+ *t++ = __wt_hex[(*p & 0xf0) >> 4];
+ *t++ = __wt_hex[*p & 0x0f];
}
*t++ = '\0';
to->size = WT_PTRDIFF(t, to->mem);