diff options
author | TingPing <tingping@tingping.se> | 2014-12-12 04:04:39 -0500 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-12-15 15:06:48 -0500 |
commit | c54a0c6db93b3fc2c6d749b79221a8d26d8afbd7 (patch) | |
tree | 78ff2c5784a7d9642cdecfce8d2cd0835eda947f /plugins/fishlim/irc.c | |
parent | 46061f4f3cad58acefeab840f9627ba9293568bb (diff) |
fishlim: Improve string handling
Diffstat (limited to 'plugins/fishlim/irc.c')
-rw-r--r-- | plugins/fishlim/irc.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/plugins/fishlim/irc.c b/plugins/fishlim/irc.c index 3586921b..c80fc1c9 100644 --- a/plugins/fishlim/irc.c +++ b/plugins/fishlim/irc.c @@ -22,8 +22,7 @@ */ -#include <stdlib.h> -#include <string.h> +#include <glib.h> #include "irc.h" /** @@ -65,7 +64,6 @@ bool irc_parse_message(const char *words[], */ char *irc_prefix_get_nick(const char *prefix) { const char *end; - char *nick; size_t length; if (!prefix) return NULL; @@ -76,13 +74,7 @@ char *irc_prefix_get_nick(const char *prefix) { // Allocate string length = end - prefix; - nick = malloc(length+1); - if (!nick) return NULL; - - // Copy to string - memcpy(nick, prefix, length); - nick[length] = '\0'; - return nick; + return g_strndup (prefix, length); } |