1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

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
This commit is contained in:
Emanuele Giaquinta 2007-04-29 12:26:02 +00:00 committed by exg
parent 983ee1db88
commit f866799bb0
2 changed files with 17 additions and 12 deletions

View File

@ -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);
}

View File

@ -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);
}