From 32ecd4ee583127defc6e0e54dbe6e4408648475e Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 4 May 2013 15:43:26 +0200 Subject: [PATCH] WUtil: Avoid unnecessary strdup + free It is not good for memory fragmentation to duplicate a string and then free the original; changed code to only keep originaly allocated string. --- WINGs/string.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/WINGs/string.c b/WINGs/string.c index 4db99813..8403d625 100644 --- a/WINGs/string.c +++ b/WINGs/string.c @@ -78,19 +78,17 @@ char *wtokennext(char *word, char **next) } } - if (*ret == 0) - t = NULL; - else - t = wstrdup(ret); - - wfree(ret); + if (*ret == 0) { + wfree(ret); + ret = NULL; + } if (ctype == PRC_EOS) *next = NULL; else *next = ptr; - return t; + return ret; } /* separate a string in tokens, taking " and ' into account */ -- 2.11.4.GIT