Permalink
Browse files

convert bot_nick to static buffer

  • Loading branch information...
1 parent 23e1761 commit 3c76d17c4056d38b3aa16d7949d18264a9db1db8 @pmer committed Apr 7, 2012
Showing with 7 additions and 19 deletions.
  1. +4 −16 plg/handle_nicknameinuse/handle_nicknameinuse.c
  2. +2 −2 yak.c
  3. +1 −1 yak.h
View
20 plg/handle_nicknameinuse/handle_nicknameinuse.c
@@ -1,27 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include "bool.h"
#include "callback.h"
#include "ircproto.h"
-#include "yak.h" /* bot_nick */
+#include "yak.h"
static void handle_nicknameinuse(char *prefix, int ncmd, char *params)
{
- static bool firsttime = true;
- char *old, *new;
-
- old = bot_nick;
- new = malloc(strlen(old) + 2);
- sprintf(new, "%s_", old);
- bot_nick = new;
-
- if (firsttime)
- firsttime = false;
- else
- free(bot_nick);
- bot_nick = new;
+ int len = strlen(bot_nick);
+ bot_nick[len++] = '_';
+ bot_nick[len] = '\0';
ircproto_nick(bot_nick);
}
@@ -34,4 +23,3 @@ int init()
void finish()
{
}
-
View
4 yak.c
@@ -18,7 +18,7 @@
char *host;
int port;
-char *bot_nick;
+char bot_nick[512];
char *bot_user;
char *bot_real;
char *nickservnick;
@@ -36,7 +36,7 @@ static void load_whoiam()
host = pref_get("host");
port_str = pref_get("port");
- bot_nick = pref_get("nick");
+ strcpy(bot_nick, pref_get("nick"));
bot_user = pref_get("user");
bot_real = pref_get("real");
nickservnick = pref_get("nickserv-nick");
View
2 yak.h
@@ -1,7 +1,7 @@
#ifndef YAK_H
#define YAK_H
-extern char *bot_nick;
+extern char bot_nick[];
extern char *bot_owners[];
#define YAK_VERSION "0.2.2"

0 comments on commit 3c76d17

Please sign in to comment.