From: Christophe CURIS <[email protected]>
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 4db9981..8403d62 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 */
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].