summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2007-04-29 12:26:02 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2007-04-29 12:26:02 +0000
commitf866799bb0acc96bdfb5e4f08da9aa9efe16c4f2 (patch)
tree72e4b9ccc4f2a040741d0f63093d40c1f7433f21 /src
parent983ee1db888e8f478990ac900ce01cfefe30c890 (diff)
downloadirssi-f866799bb0acc96bdfb5e4f08da9aa9efe16c4f2.zip
Use dynamic storage for return value of channel_get_nickmode.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4471 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/fe-messages.c26
-rw-r--r--src/fe-common/irc/fe-irc-messages.c3
2 files changed, 17 insertions, 12 deletions
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index 3080b99c..ee910f89 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -134,24 +134,25 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
static char *channel_get_nickmode_rec(NICK_REC *nickrec)
{
char *emptystr;
- static char nickmode[2]; /* FIXME: bad */
+ char *nickmode;
if (!settings_get_bool("show_nickmode"))
return "";
emptystr = settings_get_bool("show_nickmode_empty") ? " " : "";
- if (nickrec != NULL && nickrec->other) {
+ if (nickrec == NULL)
+ nickmode = g_strdup(emptystr);
+ else if (nickrec->other) {
+ nickmode = g_malloc(2);
nickmode[0] = nickrec->other;
nickmode[1] = '\0';
- return nickmode;
- }
-
- return nickrec == NULL ? emptystr :
- nickrec->op ? "@" :
- nickrec->halfop ? "%" :
- nickrec->voice ? "+" :
- emptystr;
+ } else
+ nickmode = g_strdup(nickrec->op ? "@" :
+ nickrec->halfop ? "%" :
+ nickrec->voice ? "+" :
+ emptystr);
+ return nickmode;
}
char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick)
@@ -167,9 +168,9 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
const char *target, NICK_REC *nickrec)
{
CHANNEL_REC *chanrec;
- const char *nickmode, *printnick;
+ const char *printnick;
int for_me, print_channel, level;
- char *color, *freemsg = NULL;
+ char *nickmode, *color, *freemsg = NULL;
HILIGHT_REC *hilight;
/* NOTE: this may return NULL if some channel is just closed with
@@ -229,6 +230,7 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
printnick, target, msg, nickmode);
}
+ g_free_not_null(nickmode);
g_free_not_null(freemsg);
g_free_not_null(color);
}
diff --git a/src/fe-common/irc/fe-irc-messages.c b/src/fe-common/irc/fe-irc-messages.c
index 47922d4e..5c3a95b3 100644
--- a/src/fe-common/irc/fe-irc-messages.c
+++ b/src/fe-common/irc/fe-irc-messages.c
@@ -72,6 +72,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
MSGLEVEL_NO_ACT,
TXT_OWN_MSG_CHANNEL,
server->nick, oldtarget, recoded, nickmode);
+ g_free(nickmode);
g_free(recoded);
signal_stop();
}
@@ -93,6 +94,7 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
MSGLEVEL_PUBLIC,
TXT_PUBMSG_CHANNEL,
nick, optarget, msg, nickmode);
+ g_free(nickmode);
g_free(optarget);
}
@@ -112,6 +114,7 @@ static void sig_message_own_wall(SERVER_REC *server, const char *msg,
MSGLEVEL_NO_ACT,
TXT_OWN_MSG_CHANNEL,
server->nick, optarget, recoded, nickmode);
+ g_free(nickmode);
g_free(recoded);
g_free(optarget);
}