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;