im.pidgin.pidgin: fbe2de5c539aa0d47df62237611550760cae618b
markdoliner at pidgin.im
markdoliner at pidgin.im
Mon Dec 3 04:00:48 EST 2007
-----------------------------------------------------------------
Revision: fbe2de5c539aa0d47df62237611550760cae618b
Ancestor: b00455f77016b097783d9c0eaff91d98bbd84480
Author: markdoliner at pidgin.im
Date: 2007-12-03T08:57:37
Branch: im.pidgin.pidgin
Modified files:
libpurple/protocols/oscar/family_feedbag.c
ChangeLog:
g_strdup() is awesome. 11 insertions(+), 35 deletions(-)
-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_feedbag.c 8128f3f9022a3c5fc9e6132b34e80224eec2bc19
+++ libpurple/protocols/oscar/family_feedbag.c de6a93267f8bbae30df4bf307b5a31ecfd8270d9
@@ -115,14 +115,10 @@ static struct aim_ssi_item *aim_ssi_item
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;
@@ -510,7 +506,7 @@ static int aim_ssi_sync(OscarData *od)
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 +526,7 @@ static int aim_ssi_sync(OscarData *od)
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 +547,7 @@ static int aim_ssi_sync(OscarData *od)
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 +1024,7 @@ int aim_ssi_rename_group(OscarData *od,
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 +1456,7 @@ static int parsemod(OscarData *od, FlapC
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 +1464,7 @@ static int parsemod(OscarData *od, FlapC
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 +1542,7 @@ static int parseack(OscarData *od, FlapC
/* 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 +1553,7 @@ static int parseack(OscarData *od, FlapC
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 +1583,7 @@ static int parseack(OscarData *od, FlapC
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);
}
More information about the Commits
mailing list