mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-11-06 00:35:38 +00:00
fishlim: Improve string handling
This commit is contained in:
1 parent
46061f4f3c
commit
c54a0c6db9
2 files changed
+16
-44
No files matched your search
+2
-10
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user