1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-05 21:34:17 +01:00

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.
This commit is contained in:
Christophe CURIS
2013-05-04 15:43:26 +02:00
committed by Carlos R. Mafra
parent 98e3c7e347
commit 32ecd4ee58

View File

@@ -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 */