mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-07 14:24:14 +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:
committed by
Carlos R. Mafra
parent
98e3c7e347
commit
32ecd4ee58
@@ -78,19 +78,17 @@ char *wtokennext(char *word, char **next)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ret == 0)
|
if (*ret == 0) {
|
||||||
t = NULL;
|
wfree(ret);
|
||||||
else
|
ret = NULL;
|
||||||
t = wstrdup(ret);
|
}
|
||||||
|
|
||||||
wfree(ret);
|
|
||||||
|
|
||||||
if (ctype == PRC_EOS)
|
if (ctype == PRC_EOS)
|
||||||
*next = NULL;
|
*next = NULL;
|
||||||
else
|
else
|
||||||
*next = ptr;
|
*next = ptr;
|
||||||
|
|
||||||
return t;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* separate a string in tokens, taking " and ' into account */
|
/* separate a string in tokens, taking " and ' into account */
|
||||||
|
|||||||
Reference in New Issue
Block a user