summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-05-11 11:50:26 -0400
committermidipix <writeonce@midipix.org>2016-05-11 11:55:14 -0400
commit000e5eca5ae21f0f0cbc64cb666fb63e09f6e69b (patch)
treec18b943f5cd306402c4fe49e3b35f224f75f415b
parent6114a02c8424d290c9711d8782a2d9821ef569c8 (diff)
downloaddalist-000e5eca5ae21f0f0cbc64cb666fb63e09f6e69b.tar.bz2
dalist-000e5eca5ae21f0f0cbc64cb666fb63e09f6e69b.tar.xz
dalist_dbg_write_posix(): improved selection of arch-specific strings.
-rw-r--r--src/dalist_debug.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/dalist_debug.c b/src/dalist_debug.c
index 5942076..f466989 100644
--- a/src/dalist_debug.c
+++ b/src/dalist_debug.c
@@ -75,6 +75,16 @@ static const char dalist_fmt_node_64[] =
"next: 0x%016x\t"
"any: 0x%016x\t\n";
+static const char * dalist_fmt_headers[2] = {
+ dalist_fmt_header_32,
+ dalist_fmt_header_64
+};
+
+static const char * dalist_fmt_nodes[2] = {
+ dalist_fmt_node_32,
+ dalist_fmt_node_64
+};
+
static int dalist_dbg_write_posix(
struct dalist_ex * dlist,
@@ -150,15 +160,8 @@ int dalist_debug_print(
/* initial setup */
dbg_sprintf = (dalist_sprintf *)dlist->debug->sprintf;
-
- if (sizeof(size_t) == 4) {
- fmt_header = (char *)dalist_fmt_header_32;
- fmt_node = (char *)dalist_fmt_node_32;
- } else if (sizeof(size_t) == 8) {
- fmt_header = (char *)dalist_fmt_header_64;
- fmt_node = (char *)dalist_fmt_node_64;
- } else
- return DALIST_EDEBUGENV;
+ fmt_header = dalist_fmt_headers[(sizeof(size_t)-4)/4];
+ fmt_node = dalist_fmt_nodes[(sizeof(size_t)-4)/4];
if (dlist->debug->dbgenv == DALIST_DEBUG_ENV_POSIX)
dbg_write = dalist_dbg_write_posix;