From 000e5eca5ae21f0f0cbc64cb666fb63e09f6e69b Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 11 May 2016 11:50:26 -0400 Subject: dalist_dbg_write_posix(): improved selection of arch-specific strings. --- src/dalist_debug.c | 21 ++++++++++++--------- 1 file 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; -- cgit v1.2.3