about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c144
-rw-r--r--src/common.c26
-rw-r--r--src/common.h1
-rw-r--r--src/config/accounts.c20
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/muc.c4
-rw-r--r--src/tools/autocomplete.c72
-rw-r--r--src/tools/autocomplete.h2
-rw-r--r--src/xmpp/bookmark.c4
-rw-r--r--src/xmpp/capabilities.c6
-rw-r--r--src/xmpp/iq.c2
-rw-r--r--src/xmpp/presence.c2
-rw-r--r--src/xmpp/roster.c12
-rw-r--r--src/xmpp/stanza.c4
14 files changed, 122 insertions, 181 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 41c8a2ae..626b108e 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -878,16 +878,16 @@ cmd_init(void)
     commands_ac = autocomplete_new();
 
     help_ac = autocomplete_new();
-    autocomplete_add(help_ac, strdup("commands"));
-    autocomplete_add(help_ac, strdup("basic"));
-    autocomplete_add(help_ac, strdup("chatting"));
-    autocomplete_add(help_ac, strdup("groupchat"));
-    autocomplete_add(help_ac, strdup("presence"));
-    autocomplete_add(help_ac, strdup("contacts"));
-    autocomplete_add(help_ac, strdup("service"));
-    autocomplete_add(help_ac, strdup("settings"));
-    autocomplete_add(help_ac, strdup("other"));
-    autocomplete_add(help_ac, strdup("navigation"));
+    autocomplete_add(help_ac, "commands");
+    autocomplete_add(help_ac, "basic");
+    autocomplete_add(help_ac, "chatting");
+    autocomplete_add(help_ac, "groupchat");
+    autocomplete_add(help_ac, "presence");
+    autocomplete_add(help_ac, "contacts");
+    autocomplete_add(help_ac, "service");
+    autocomplete_add(help_ac, "settings");
+    autocomplete_add(help_ac, "other");
+    autocomplete_add(help_ac, "navigation");
 
     // load command defs into hash table
     commands = g_hash_table_new(g_str_hash, g_str_equal);
@@ -899,102 +899,102 @@ cmd_init(void)
         g_hash_table_insert(commands, pcmd->cmd, pcmd);
 
         // add to commands and help autocompleters
-        autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd));
-        autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1));
+        autocomplete_add(commands_ac, pcmd->cmd);
+        autocomplete_add(help_ac, pcmd->cmd+1);
     }
 
     prefs_ac = autocomplete_new();
-    autocomplete_add(prefs_ac, strdup("ui"));
-    autocomplete_add(prefs_ac, strdup("desktop"));
-    autocomplete_add(prefs_ac, strdup("chat"));
-    autocomplete_add(prefs_ac, strdup("log"));
-    autocomplete_add(prefs_ac, strdup("conn"));
-    autocomplete_add(prefs_ac, strdup("presence"));
+    autocomplete_add(prefs_ac, "ui");
+    autocomplete_add(prefs_ac, "desktop");
+    autocomplete_add(prefs_ac, "chat");
+    autocomplete_add(prefs_ac, "log");
+    autocomplete_add(prefs_ac, "conn");
+    autocomplete_add(prefs_ac, "presence");
 
     notify_ac = autocomplete_new();
-    autocomplete_add(notify_ac, strdup("message"));
-    autocomplete_add(notify_ac, strdup("typing"));
-    autocomplete_add(notify_ac, strdup("remind"));
-    autocomplete_add(notify_ac, strdup("invite"));
-    autocomplete_add(notify_ac, strdup("sub"));
+    autocomplete_add(notify_ac, "message");
+    autocomplete_add(notify_ac, "typing");
+    autocomplete_add(notify_ac, "remind");
+    autocomplete_add(notify_ac, "invite");
+    autocomplete_add(notify_ac, "sub");
 
     sub_ac = autocomplete_new();
-    autocomplete_add(sub_ac, strdup("request"));
-    autocomplete_add(sub_ac, strdup("allow"));
-    autocomplete_add(sub_ac, strdup("deny"));
-    autocomplete_add(sub_ac, strdup("show"));
-    autocomplete_add(sub_ac, strdup("sent"));
-    autocomplete_add(sub_ac, strdup("received"));
+    autocomplete_add(sub_ac, "request");
+    autocomplete_add(sub_ac, "allow");
+    autocomplete_add(sub_ac, "deny");
+    autocomplete_add(sub_ac, "show");
+    autocomplete_add(sub_ac, "sent");
+    autocomplete_add(sub_ac, "received");
 
     titlebar_ac = autocomplete_new();
-    autocomplete_add(titlebar_ac, strdup("version"));
+    autocomplete_add(titlebar_ac, "version");
 
     log_ac = autocomplete_new();
-    autocomplete_add(log_ac, strdup("maxsize"));
+    autocomplete_add(log_ac, "maxsize");
 
     autoaway_ac = autocomplete_new();
-    autocomplete_add(autoaway_ac, strdup("mode"));
-    autocomplete_add(autoaway_ac, strdup("time"));
-    autocomplete_add(autoaway_ac, strdup("message"));
-    autocomplete_add(autoaway_ac, strdup("check"));
+    autocomplete_add(autoaway_ac, "mode");
+    autocomplete_add(autoaway_ac, "time");
+    autocomplete_add(autoaway_ac, "message");
+    autocomplete_add(autoaway_ac, "check");
 
     autoaway_mode_ac = autocomplete_new();
-    autocomplete_add(autoaway_mode_ac, strdup("away"));
-    autocomplete_add(autoaway_mode_ac, strdup("idle"));
-    autocomplete_add(autoaway_mode_ac, strdup("off"));
+    autocomplete_add(autoaway_mode_ac, "away");
+    autocomplete_add(autoaway_mode_ac, "idle");
+    autocomplete_add(autoaway_mode_ac, "off");
 
     theme_ac = autocomplete_new();
-    autocomplete_add(theme_ac, strdup("list"));
-    autocomplete_add(theme_ac, strdup("set"));
+    autocomplete_add(theme_ac, "list");
+    autocomplete_add(theme_ac, "set");
 
     disco_ac = autocomplete_new();
-    autocomplete_add(disco_ac, strdup("info"));
-    autocomplete_add(disco_ac, strdup("items"));
+    autocomplete_add(disco_ac, "info");
+    autocomplete_add(disco_ac, "items");
 
     account_ac = autocomplete_new();
-    autocomplete_add(account_ac, strdup("list"));
-    autocomplete_add(account_ac, strdup("show"));
-    autocomplete_add(account_ac, strdup("add"));
-    autocomplete_add(account_ac, strdup("enable"));
-    autocomplete_add(account_ac, strdup("disable"));
-    autocomplete_add(account_ac, strdup("rename"));
-    autocomplete_add(account_ac, strdup("set"));
+    autocomplete_add(account_ac, "list");
+    autocomplete_add(account_ac, "show");
+    autocomplete_add(account_ac, "add");
+    autocomplete_add(account_ac, "enable");
+    autocomplete_add(account_ac, "disable");
+    autocomplete_add(account_ac, "rename");
+    autocomplete_add(account_ac, "set");
 
     close_ac = autocomplete_new();
-    autocomplete_add(close_ac, strdup("read"));
-    autocomplete_add(close_ac, strdup("all"));
+    autocomplete_add(close_ac, "read");
+    autocomplete_add(close_ac, "all");
 
     wins_ac = autocomplete_new();
-    autocomplete_add(wins_ac, strdup("prune"));
-    autocomplete_add(wins_ac, strdup("tidy"));
+    autocomplete_add(wins_ac, "prune");
+    autocomplete_add(wins_ac, "tidy");
 
     roster_ac = autocomplete_new();
-    autocomplete_add(roster_ac, strdup("add"));
-    autocomplete_add(roster_ac, strdup("nick"));
-    autocomplete_add(roster_ac, strdup("remove"));
+    autocomplete_add(roster_ac, "add");
+    autocomplete_add(roster_ac, "nick");
+    autocomplete_add(roster_ac, "remove");
 
     group_ac = autocomplete_new();
-    autocomplete_add(group_ac, strdup("show"));
-    autocomplete_add(group_ac, strdup("add"));
-    autocomplete_add(group_ac, strdup("remove"));
+    autocomplete_add(group_ac, "show");
+    autocomplete_add(group_ac, "add");
+    autocomplete_add(group_ac, "remove");
 
     theme_load_ac = NULL;
 
     who_ac = autocomplete_new();
-    autocomplete_add(who_ac, strdup("chat"));
-    autocomplete_add(who_ac, strdup("online"));
-    autocomplete_add(who_ac, strdup("away"));
-    autocomplete_add(who_ac, strdup("xa"));
-    autocomplete_add(who_ac, strdup("dnd"));
-    autocomplete_add(who_ac, strdup("offline"));
-    autocomplete_add(who_ac, strdup("available"));
-    autocomplete_add(who_ac, strdup("unavailable"));
-    autocomplete_add(who_ac, strdup("any"));
+    autocomplete_add(who_ac, "chat");
+    autocomplete_add(who_ac, "online");
+    autocomplete_add(who_ac, "away");
+    autocomplete_add(who_ac, "xa");
+    autocomplete_add(who_ac, "dnd");
+    autocomplete_add(who_ac, "offline");
+    autocomplete_add(who_ac, "available");
+    autocomplete_add(who_ac, "unavailable");
+    autocomplete_add(who_ac, "any");
 
     bookmark_ac = autocomplete_new();
-    autocomplete_add(bookmark_ac, strdup("add"));
-    autocomplete_add(bookmark_ac, strdup("list"));
-    autocomplete_add(bookmark_ac, strdup("remove"));
+    autocomplete_add(bookmark_ac, "add");
+    autocomplete_add(bookmark_ac, "list");
+    autocomplete_add(bookmark_ac, "remove");
 
     cmd_history_init();
 }
@@ -3813,7 +3813,7 @@ _theme_autocomplete(char *input, int *size)
             theme_load_ac = autocomplete_new();
             GSList *themes = theme_list();
             while (themes != NULL) {
-                autocomplete_add(theme_load_ac, strdup(themes->data));
+                autocomplete_add(theme_load_ac, themes->data);
                 themes = g_slist_next(themes);
             }
             g_slist_free(themes);
diff --git a/src/common.c b/src/common.c
index da33cc3d..c7ec7d0b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -225,32 +225,6 @@ prof_getline(FILE *stream)
     return s;
 }
 
-int
-octet_compare(unsigned char *str1, unsigned char *str2)
-{
-    if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") == 0)) {
-        return 0;
-    }
-
-    if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") != 0)) {
-        return -1;
-    }
-
-    if ((strcmp((char *)str1, "") != 0) && (strcmp((char *)str2, "") == 0)) {
-        return 1;
-    }
-
-    if (str1[0] == str2[0]) {
-        return octet_compare(&str1[1], &str2[1]);
-    }
-
-    if (str1[0] < str2[0]) {
-        return -1;
-    }
-
-    return 1;
-}
-
 char *
 release_get_latest()
 {
diff --git a/src/common.h b/src/common.h
index 469a63ec..f2b59413 100644
--- a/src/common.h
+++ b/src/common.h
@@ -79,7 +79,6 @@ char * str_replace(const char *string, const char *substr,
 int str_contains(char str[], int size, char ch);
 char* encode_xml(const char * const xml);
 char * prof_getline(FILE *stream);
-int octet_compare(unsigned char *str1, unsigned char *str2);
 char* release_get_latest(void);
 gboolean release_is_new(char *found_version);
 gchar * xdg_get_config_home(void);
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 3d198874..3e3daec0 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -64,9 +64,9 @@ accounts_load(void)
 
     gsize i;
     for (i = 0; i < naccounts; i++) {
-        autocomplete_add(all_ac, strdup(account_names[i]));
+        autocomplete_add(all_ac, account_names[i]);
         if (g_key_file_get_boolean(accounts, account_names[i], "enabled", NULL)) {
-            autocomplete_add(enabled_ac, strdup(account_names[i]));
+            autocomplete_add(enabled_ac, account_names[i]);
         }
 
         _fix_legacy_accounts(account_names[i]);
@@ -138,8 +138,8 @@ accounts_add(const char *account_name, const char *altdomain)
         g_key_file_set_integer(accounts, account_name, "priority.dnd", 0);
 
         _save_accounts();
-        autocomplete_add(all_ac, strdup(account_name));
-        autocomplete_add(enabled_ac, strdup(account_name));
+        autocomplete_add(all_ac, account_name);
+        autocomplete_add(enabled_ac, account_name);
     }
 
     jid_destroy(jid);
@@ -260,7 +260,7 @@ accounts_enable(const char * const name)
     if (g_key_file_has_group(accounts, name)) {
         g_key_file_set_boolean(accounts, name, "enabled", TRUE);
         _save_accounts();
-        autocomplete_add(enabled_ac, strdup(name));
+        autocomplete_add(enabled_ac, name);
         return TRUE;
     } else {
         return FALSE;
@@ -273,7 +273,7 @@ accounts_disable(const char * const name)
     if (g_key_file_has_group(accounts, name)) {
         g_key_file_set_boolean(accounts, name, "enabled", FALSE);
         _save_accounts();
-        autocomplete_remove(enabled_ac, strdup(name));
+        autocomplete_remove(enabled_ac, name);
         return TRUE;
     } else {
         return FALSE;
@@ -317,11 +317,11 @@ accounts_rename(const char * const account_name, const char * const new_name)
     g_key_file_remove_group(accounts, account_name, NULL);
     _save_accounts();
 
-    autocomplete_remove(all_ac, strdup(account_name));
-    autocomplete_add(all_ac, strdup(new_name));
+    autocomplete_remove(all_ac, account_name);
+    autocomplete_add(all_ac, new_name);
     if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) {
-        autocomplete_remove(enabled_ac, strdup(account_name));
-        autocomplete_add(enabled_ac, strdup(new_name));
+        autocomplete_remove(enabled_ac, account_name);
+        autocomplete_add(enabled_ac, new_name);
     }
 
     return TRUE;
diff --git a/src/config/preferences.c b/src/config/preferences.c
index fe34e00e..1d417e41 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -77,8 +77,8 @@ prefs_load(void)
     }
 
     boolean_choice_ac = autocomplete_new();
-    autocomplete_add(boolean_choice_ac, strdup("on"));
-    autocomplete_add(boolean_choice_ac, strdup("off"));
+    autocomplete_add(boolean_choice_ac, "on");
+    autocomplete_add(boolean_choice_ac, "off");
 }
 
 void
diff --git a/src/muc.c b/src/muc.c
index 1d5b910a..93202a54 100644
--- a/src/muc.c
+++ b/src/muc.c
@@ -57,7 +57,7 @@ muc_init(void)
 void
 muc_add_invite(char *room)
 {
-    autocomplete_add(invite_ac, strdup(room));
+    autocomplete_add(invite_ac, room);
 }
 
 void
@@ -298,7 +298,7 @@ muc_add_to_roster(const char * const room, const char * const nick,
 
         if (old == NULL) {
             updated = TRUE;
-            autocomplete_add(chat_room->nick_ac, strdup(nick));
+            autocomplete_add(chat_room->nick_ac, nick);
         } else if ((g_strcmp0(p_contact_presence(old), show) != 0) ||
                     (g_strcmp0(p_contact_status(old), status) != 0)) {
             updated = TRUE;
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 5c70f874..77d8c7ae 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -83,71 +83,39 @@ autocomplete_length(Autocomplete ac)
 }
 
 gboolean
-autocomplete_add(Autocomplete ac, void *item)
+autocomplete_add(Autocomplete ac, const char *item)
 {
-    if (ac->items == NULL) {
-        ac->items = g_slist_append(ac->items, item);
-        return TRUE;
-    } else {
-        GSList *curr = ac->items;
-
-        while(curr) {
-
-            // insert
-            if (g_strcmp0(curr->data, item) > 0) {
-                ac->items = g_slist_insert_before(ac->items,
-                    curr, item);
-                return TRUE;
-
-            // update
-            } else if (g_strcmp0(curr->data, item) == 0) {
-                // only update if data different
-                if (strcmp(curr->data, item) != 0) {
-                    free(curr->data);
-                    curr->data = item;
-                    return TRUE;
-                } else {
-                    return FALSE;
-                }
-            }
-
-            curr = g_slist_next(curr);
-        }
+    char *item_cpy;
+    GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
 
-        // hit end, append
-        ac->items = g_slist_append(ac->items, item);
-
-        return TRUE;
+    // if item already exists
+    if (curr != NULL) {
+        return FALSE;
     }
+
+    item_cpy = strdup(item);
+    ac->items = g_slist_insert_sorted(ac->items, item_cpy, (GCompareFunc)strcmp);
+    return TRUE;
 }
 
 gboolean
 autocomplete_remove(Autocomplete ac, const char * const item)
 {
-    // reset last found if it points to the item to be removed
-    if (ac->last_found != NULL)
-        if (g_strcmp0(ac->last_found->data, item) == 0)
-            ac->last_found = NULL;
+    GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
 
-    if (!ac->items) {
+    if (!curr) {
         return FALSE;
-    } else {
-        GSList *curr = ac->items;
-
-        while(curr) {
-            if (g_strcmp0(curr->data, item) == 0) {
-                void *current_item = curr->data;
-                ac->items = g_slist_remove(ac->items, curr->data);
-                free(current_item);
+    }
 
-                return TRUE;
-            }
+    // reset last found if it points to the item to be removed
+    if (ac->last_found == curr) {
+        ac->last_found = NULL;
+    }
 
-            curr = g_slist_next(curr);
-        }
+    free(curr->data);
+    ac->items = g_slist_delete_link(ac->items, curr);
 
-        return FALSE;
-    }
+    return TRUE;
 }
 
 GSList *
diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h
index a28601d0..908e273e 100644
--- a/src/tools/autocomplete.h
+++ b/src/tools/autocomplete.h
@@ -38,7 +38,7 @@ Autocomplete obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
 void autocomplete_clear(Autocomplete ac);
 void autocomplete_reset(Autocomplete ac);
 void autocomplete_free(Autocomplete ac);
-gboolean autocomplete_add(Autocomplete ac, void *item);
+gboolean autocomplete_add(Autocomplete ac, const char *item);
 gboolean autocomplete_remove(Autocomplete ac, const char * const item);
 GSList * autocomplete_get_list(Autocomplete ac);
 gchar * autocomplete_complete(Autocomplete ac, gchar *search_str);
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c
index 92e6d7e8..0818f9ee 100644
--- a/src/xmpp/bookmark.c
+++ b/src/xmpp/bookmark.c
@@ -69,7 +69,7 @@ bookmark_add(const char *jid, const char *nick, gboolean autojoin)
 
     /* this may be command for modifying */
     autocomplete_remove(bookmark_ac, jid);
-    autocomplete_add(bookmark_ac, strdup(jid));
+    autocomplete_add(bookmark_ac, jid);
 }
 
 void
@@ -174,7 +174,7 @@ _bookmark_handle_result(xmpp_conn_t * const conn,
             autojoin_val = FALSE;
         }
 
-        autocomplete_add(bookmark_ac, strdup(jid));
+        autocomplete_add(bookmark_ac, jid);
         item = malloc(sizeof(*item));
         item->jid = strdup(jid);
         item->nick = name;
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index 2b0a12e5..f38a2749 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -148,15 +148,15 @@ caps_create_sha1_str(xmpp_stanza_t * const query)
                 g_string_append(identity_str, name);
             }
             g_string_append(identity_str, "<");
-            identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)octet_compare);
+            identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)strcmp);
             g_string_free(identity_str, TRUE);
         } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_FEATURE) == 0) {
             feature_str = xmpp_stanza_get_attribute(child, "var");
-            features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)octet_compare);
+            features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)strcmp);
         } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_X) == 0) {
             if (strcmp(xmpp_stanza_get_ns(child), STANZA_NS_DATA) == 0) {
                 form = stanza_create_form(child);
-                form_names = g_slist_insert_sorted(form_names, g_strdup(form->form_type), (GCompareFunc)octet_compare);
+                form_names = g_slist_insert_sorted(form_names, g_strdup(form->form_type), (GCompareFunc)strcmp);
                 g_hash_table_insert(forms, g_strdup(form->form_type), form);
             }
         }
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 5de84056..8eb4d99e 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -247,7 +247,7 @@ _iq_handle_version_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
         xmpp_send(conn, response);
 
-        g_free(version_str);
+        g_string_free(version_str, TRUE);
         xmpp_stanza_release(name_txt);
         xmpp_stanza_release(version_txt);
         xmpp_stanza_release(name);
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index ec439871..607bb02b 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -372,7 +372,7 @@ _subscribe_handler(xmpp_conn_t * const conn,
     }
 
     prof_handle_subscription(from_jid->barejid, PRESENCE_SUBSCRIBE);
-    autocomplete_add(sub_requests_ac, strdup(from_jid->barejid));
+    autocomplete_add(sub_requests_ac, from_jid->barejid);
 
     jid_destroy(from_jid);
 
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index b31a2725..c073464d 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -184,12 +184,12 @@ roster_add(const char * const barejid, const char * const name, GSList *groups,
 
         // add groups
         while (groups != NULL) {
-            autocomplete_add(groups_ac, strdup(groups->data));
+            autocomplete_add(groups_ac, groups->data);
             groups = g_slist_next(groups);
         }
 
         g_hash_table_insert(contacts, strdup(barejid), contact);
-        autocomplete_add(barejid_ac, strdup(barejid));
+        autocomplete_add(barejid_ac, barejid);
         _add_name_and_barejid(name, barejid);
 
         if (!from_initial) {
@@ -226,7 +226,7 @@ roster_update(const char * const barejid, const char * const name,
 
         // add groups
         while (groups != NULL) {
-            autocomplete_add(groups_ac, strdup(groups->data));
+            autocomplete_add(groups_ac, groups->data);
             groups = g_slist_next(groups);
         }
     }
@@ -248,7 +248,7 @@ roster_update_presence(const char * const barejid, Resource *resource,
     }
     p_contact_set_presence(contact, resource);
     Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name);
-    autocomplete_add(fulljid_ac, strdup(jid->fulljid));
+    autocomplete_add(fulljid_ac, jid->fulljid);
     jid_destroy(jid);
 
     return TRUE;
@@ -646,10 +646,10 @@ static void
 _add_name_and_barejid(const char * const name, const char * const barejid)
 {
     if (name != NULL) {
-        autocomplete_add(name_ac, strdup(name));
+        autocomplete_add(name_ac, name);
         g_hash_table_insert(name_to_barejid, strdup(name), strdup(barejid));
     } else {
-        autocomplete_add(name_ac, strdup(barejid));
+        autocomplete_add(name_ac, barejid);
         g_hash_table_insert(name_to_barejid, strdup(barejid), strdup(barejid));
     }
 }
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 7d7a0949..97cebc73 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -853,7 +853,7 @@ stanza_create_form(xmpp_stanza_t * const stanza)
             while (value != NULL) {
                 char *text = xmpp_stanza_get_text(value);
                 if (text != NULL) {
-                    field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)octet_compare);
+                    field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)strcmp);
                     xmpp_free(ctx, text);
                 }
                 value = xmpp_stanza_get_next(value);
@@ -997,5 +997,5 @@ stanza_get_presence_string_from_type(resource_presence_t presence_type)
 static int
 _field_compare(FormField *f1, FormField *f2)
 {
-    return octet_compare((unsigned char *)f1->var, (unsigned char *)f2->var);
+    return strcmp(f1->var, f2->var);
 }