Mercurial > pidgin.yaz
diff libpurple/protocols/oscar/family_feedbag.c @ 27746:e13759a83714
propagate from branch 'im.pidgin.pidgin' (head cff05fbceab1d88163770d13a4c7a6116bdeb8ee)
to branch 'im.pidgin.pidgin.yaz' (head 4c2ca466febbc129edc2012fd6ce5769696116d0)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 15 Dec 2007 05:15:31 +0000 |
parents | 477b020d5945 |
children | 979a81468e19 |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_feedbag.c Sat Dec 15 05:12:24 2007 +0000 +++ b/libpurple/protocols/oscar/family_feedbag.c Sat Dec 15 05:15:31 2007 +0000 @@ -115,14 +115,10 @@ gboolean exists; struct aim_ssi_item *cur, *new; - new = (struct aim_ssi_item *)g_malloc(sizeof(struct aim_ssi_item)); + new = g_new(struct aim_ssi_item, 1); /* Set the name */ - if (name) { - new->name = (char *)g_malloc((strlen(name)+1)*sizeof(char)); - strcpy(new->name, name); - } else - new->name = NULL; + new->name = g_strdup(name); /* Set the group ID# and buddy ID# */ new->gid = gid; @@ -345,13 +341,9 @@ */ struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *sn) { - struct aim_ssi_item *cur; - if (!list || !sn) + if (!sn) return NULL; - for (cur=list; cur; cur=cur->next) - if ((cur->type == AIM_SSI_TYPE_BUDDY) && (cur->name) && (!aim_sncmp(cur->name, sn))) - return cur; - return NULL; + return aim_ssi_itemlist_finditem(list, NULL, sn, AIM_SSI_TYPE_BUDDY); } /** @@ -510,7 +502,7 @@ for (cur1=od->ssi.official; cur1 && (n < 15); cur1=cur1->next) { if (!aim_ssi_itemlist_find(od->ssi.local, cur1->gid, cur1->bid)) { n++; - new = (struct aim_ssi_tmp *)g_malloc(sizeof(struct aim_ssi_tmp)); + new = g_new(struct aim_ssi_tmp, 1); new->action = SNAC_SUBTYPE_FEEDBAG_DEL; new->ack = 0xffff; new->name = NULL; @@ -530,7 +522,7 @@ for (cur1=od->ssi.local; cur1 && (n < 15); cur1=cur1->next) { if (!aim_ssi_itemlist_find(od->ssi.official, cur1->gid, cur1->bid)) { n++; - new = (struct aim_ssi_tmp *)g_malloc(sizeof(struct aim_ssi_tmp)); + new = g_new(struct aim_ssi_tmp, 1); new->action = SNAC_SUBTYPE_FEEDBAG_ADD; new->ack = 0xffff; new->name = NULL; @@ -551,7 +543,7 @@ cur2 = aim_ssi_itemlist_find(od->ssi.official, cur1->gid, cur1->bid); if (cur2 && (aim_ssi_itemlist_cmp(cur1, cur2))) { n++; - new = (struct aim_ssi_tmp *)g_malloc(sizeof(struct aim_ssi_tmp)); + new = g_new(struct aim_ssi_tmp, 1); new->action = SNAC_SUBTYPE_FEEDBAG_MOD; new->ack = 0xffff; new->name = NULL; @@ -1028,8 +1020,7 @@ return -EINVAL; g_free(group->name); - group->name = (char *)g_malloc((strlen(newgn)+1)*sizeof(char)); - strcpy(group->name, newgn); + group->name = g_strdup(newgn); /* Sync our local list with the server list */ return aim_ssi_sync(od); @@ -1461,11 +1452,7 @@ if ((item = aim_ssi_itemlist_find(od->ssi.local, gid, bid))) { item->type = type; g_free(item->name); - if (name) { - item->name = (char *)g_malloc((strlen(name)+1)*sizeof(char)); - strcpy(item->name, name); - } else - item->name = NULL; + item->name = g_strdup(name); aim_tlvlist_free(item->data); item->data = aim_tlvlist_copy(data); } @@ -1473,11 +1460,7 @@ if ((item = aim_ssi_itemlist_find(od->ssi.official, gid, bid))) { item->type = type; g_free(item->name); - if (name) { - item->name = (char *)g_malloc((strlen(name)+1)*sizeof(char)); - strcpy(item->name, name); - } else - item->name = NULL; + item->name = g_strdup(name); aim_tlvlist_free(item->data); item->data = aim_tlvlist_copy(data); } @@ -1555,10 +1538,7 @@ /* Remove the item from the local list */ /* Make sure cur->item is still valid memory */ if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) { - if (cur->item->name) { - cur->name = (char *)g_malloc((strlen(cur->item->name)+1)*sizeof(char)); - strcpy(cur->name, cur->item->name); - } + cur->name = g_strdup(cur->item->name); aim_ssi_itemlist_del(&od->ssi.local, cur->item); } cur->item = NULL; @@ -1569,11 +1549,7 @@ struct aim_ssi_item *cur1; if ((cur1 = aim_ssi_itemlist_find(od->ssi.official, cur->item->gid, cur->item->bid))) { g_free(cur->item->name); - if (cur1->name) { - cur->item->name = (char *)g_malloc((strlen(cur1->name)+1)*sizeof(char)); - strcpy(cur->item->name, cur1->name); - } else - cur->item->name = NULL; + cur->item->name = g_strdup(cur1->name); aim_tlvlist_free(cur->item->data); cur->item->data = aim_tlvlist_copy(cur1->data); } @@ -1603,11 +1579,7 @@ struct aim_ssi_item *cur1; if ((cur1 = aim_ssi_itemlist_find(od->ssi.official, cur->item->gid, cur->item->bid))) { g_free(cur1->name); - if (cur->item->name) { - cur1->name = (char *)g_malloc((strlen(cur->item->name)+1)*sizeof(char)); - strcpy(cur1->name, cur->item->name); - } else - cur1->name = NULL; + cur1->name = g_strdup(cur->item->name); aim_tlvlist_free(cur1->data); cur1->data = aim_tlvlist_copy(cur->item->data); }