src/irc_user.c
changeset 74 11ec458d1cbf
parent 72 43084f103c2a
child 78 941bb8379d3d
--- a/src/irc_user.c	Thu Mar 26 22:03:20 2009 +0200
+++ b/src/irc_user.c	Thu Mar 26 22:54:25 2009 +0200
@@ -1,19 +1,28 @@
 #include "irc_user.h"
+#include "log.h"
 
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
+
+// XXX: prototype of function from irc_net
+void irc_net_remove_user (struct irc_net *net, struct irc_user *user);
 
 err_t irc_user_create (struct irc_user **user_ptr, struct irc_net *net, const char *nickname)
 {
     struct irc_user *user;
+
+    (void) net;
     
     // allocate
     if ((user = calloc(1, sizeof(*user))) == NULL)
         return ERR_CALLOC;
 
-    // copy nickname
+    // init
     if ((user->nickname = strdup(nickname)) == NULL)
         return ERR_STRDUP;
+    
+    user->refcount = 0;
 
     // ok
     *user_ptr = user;
@@ -23,6 +32,9 @@
 
 void irc_user_destroy (struct irc_user *user)
 {
+    if (user->refcount > 0)
+        log_warn("refcount=%zu", user->refcount);
+
     free(user->nickname);
     free(user);
 }