From 7a0951afc60747be67d97318d124fbdeb00bf956 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 18 Oct 2013 23:58:33 -0400 Subject: [PATCH] simplify string_is_empty --- src/misc_tools.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/misc_tools.c b/src/misc_tools.c index c521be8..d6493fd 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -50,14 +50,10 @@ void print_time(WINDOW *window) wattroff(window, COLOR_PAIR(CYAN)); } -/* check that the string has one non-space character */ +/* Returns 1 if the string is empty, 0 otherwise */ int string_is_empty(char *string) { - int rc = 0; - char *copy = strdup(string); - rc = ((strtok(copy, " ") == NULL) ? 1 : 0); - free(copy); - return rc; + return strlen(string) <= 0; } /* convert wide characters to null terminated string */