summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-12-04 19:51:38 -0500
committerMichael Cahill <michael.cahill@mongodb.com>2016-12-05 11:51:38 +1100
commita9104cf7b4d1e2f010b258b4f97db01d1ea644f2 (patch)
tree4e06191b2032da1eb7e9c3fa0a37a57794abc8ca
parent2f18a859cea47f0352cea9fbd64b396e52095ed8 (diff)
downloadmongo-a9104cf7b4d1e2f010b258b4f97db01d1ea644f2.tar.gz
WT-3051 Remove external __wt_hex symbol. (#3172)
-rw-r--r--src/btree/bt_debug.c2
-rw-r--r--src/cursor/cur_json.c4
-rw-r--r--src/include/misc.h3
-rw-r--r--src/include/misc.i10
-rw-r--r--src/support/hex.c10
5 files changed, 17 insertions, 12 deletions
diff --git a/src/btree/bt_debug.c b/src/btree/bt_debug.c
index dfbd56f7f41..3352b797fa9 100644
--- a/src/btree/bt_debug.c
+++ b/src/btree/bt_debug.c
@@ -77,7 +77,7 @@ static inline int
__debug_hex_byte(WT_DBG *ds, uint8_t v)
{
return (ds->f(
- ds, "#%c%c", __wt_hex[(v & 0xf0) >> 4], __wt_hex[v & 0x0f]));
+ ds, "#%c%c", __wt_hex((v & 0xf0) >> 4), __wt_hex(v & 0x0f)));
}
/*
diff --git a/src/cursor/cur_json.c b/src/cursor/cur_json.c
index 4ba10ddabb0..df30129262f 100644
--- a/src/cursor/cur_json.c
+++ b/src/cursor/cur_json.c
@@ -357,8 +357,8 @@ __wt_json_unpack_char(u_char ch, u_char *buf, size_t bufsz, bool force_unicode)
*buf++ = 'u';
*buf++ = '0';
*buf++ = '0';
- *buf++ = __wt_hex[(ch & 0xf0) >> 4];
- *buf++ = __wt_hex[ch & 0x0f];
+ *buf++ = __wt_hex((ch & 0xf0) >> 4);
+ *buf++ = __wt_hex(ch & 0x0f);
}
return (6);
}
diff --git a/src/include/misc.h b/src/include/misc.h
index 83e238b0529..66d43496e93 100644
--- a/src/include/misc.h
+++ b/src/include/misc.h
@@ -275,6 +275,3 @@ union __wt_rand_state {
uint32_t w, z;
} x;
};
-
-/* Shared array for converting to hex */
-extern const u_char __wt_hex[];
diff --git a/src/include/misc.i b/src/include/misc.i
index befd480e085..f36be32d6a2 100644
--- a/src/include/misc.i
+++ b/src/include/misc.i
@@ -19,6 +19,16 @@ __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs)
}
/*
+ * __wt_hex --
+ * Convert a byte to a hex character.
+ */
+static inline u_char
+__wt_hex(int c)
+{
+ return ((u_char)"0123456789abcdef"[c]);
+}
+
+/*
* __wt_strdup --
* ANSI strdup function.
*/
diff --git a/src/support/hex.c b/src/support/hex.c
index 5c48ce8b74a..b54a08dd8f3 100644
--- a/src/support/hex.c
+++ b/src/support/hex.c
@@ -8,8 +8,6 @@
#include "wt_internal.h"
-const u_char __wt_hex[] = "0123456789abcdef";
-
/*
* __fill_hex --
* In-memory conversion of raw bytes to a hexadecimal representation.
@@ -25,8 +23,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++ = __wt_hex[(*src & 0xf0) >> 4];
- *dest++ = __wt_hex[*src & 0x0f];
+ *dest++ = __wt_hex((*src & 0xf0) >> 4);
+ *dest++ = __wt_hex(*src & 0x0f);
}
*dest++ = '\0';
if (lenp != NULL)
@@ -90,8 +88,8 @@ __wt_raw_to_esc_hex(
*t++ = *p;
} else {
*t++ = '\\';
- *t++ = __wt_hex[(*p & 0xf0) >> 4];
- *t++ = __wt_hex[*p & 0x0f];
+ *t++ = __wt_hex((*p & 0xf0) >> 4);
+ *t++ = __wt_hex(*p & 0x0f);
}
*t++ = '\0';
to->size = WT_PTRDIFF(t, to->mem);