Mercurial > pidgin
changeset 14519:e548832f0e82
[gaim-migrate @ 17239]
We don't need to dynamically allocate all of these buffers.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Mon, 11 Sep 2006 02:02:18 +0000 |
parents | 7e8dbf00f7a7 |
children | 82b59abcaee4 |
files | libgaim/protocols/qq/buddy_info.c libgaim/protocols/qq/buddy_opt.c libgaim/protocols/qq/group_search.c |
diffstat | 3 files changed, 15 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/libgaim/protocols/qq/buddy_info.c Mon Sep 11 01:57:20 2006 +0000 +++ b/libgaim/protocols/qq/buddy_info.c Mon Sep 11 02:02:18 2006 +0000 @@ -285,13 +285,13 @@ void qq_send_packet_get_info(GaimConnection *gc, guint32 uid, gboolean show_window) { qq_data *qd; - gchar *uid_str; + gchar uid_str[11]; qq_info_query *query; g_return_if_fail(gc != NULL && gc->proto_data != NULL && uid != 0); qd = (qq_data *) gc->proto_data; - uid_str = g_strdup_printf("%d", uid); + g_snprintf(uid_str, sizeof(uid_str), "%d", uid); qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, TRUE, 0, TRUE, (guint8 *) uid_str, strlen(uid_str)); query = g_new0(qq_info_query, 1); @@ -299,8 +299,6 @@ query->show_window = show_window; query->modify_info = FALSE; qd->info_query = g_list_append(qd->info_query, query); - - g_free(uid_str); } /* set up the fields requesting personal information and send a get_info packet
--- a/libgaim/protocols/qq/buddy_opt.c Mon Sep 11 01:57:20 2006 +0000 +++ b/libgaim/protocols/qq/buddy_opt.c Mon Sep 11 02:02:18 2006 +0000 @@ -59,15 +59,13 @@ /* send packet to remove a buddy from my buddy list */ static void _qq_send_packet_remove_buddy(GaimConnection *gc, guint32 uid) { - gchar *uid_str; + gchar uid_str[11]; g_return_if_fail(gc != NULL && uid > 0); - uid_str = g_strdup_printf("%d", uid); + g_snprintf(uid_str, sizeof(uid_str), "%d", uid); qq_send_cmd(gc, QQ_CMD_DEL_FRIEND, TRUE, 0, TRUE, (guint8 *) uid_str, strlen(uid_str)); - - g_free(uid_str); } /* try to remove myself from someone's buddy list */ @@ -89,15 +87,14 @@ { qq_data *qd; qq_add_buddy_request *req; - gchar *uid_str; + gchar uid_str[11]; g_return_if_fail(gc != NULL && gc->proto_data != NULL && uid > 0); /* we need to send the ascii code of this uid to qq server */ - uid_str = g_strdup_printf("%d", uid); + g_snprintf(uid_str, sizeof(uid_str), "%d", uid); qq_send_cmd(gc, QQ_CMD_ADD_FRIEND_WO_AUTH, TRUE, 0, TRUE, (guint8 *) uid_str, strlen(uid_str)); - g_free(uid_str); /* must be set after sending packet to get the correct send_seq */ qd = (qq_data *) gc->proto_data; @@ -110,12 +107,12 @@ /* this buddy needs authentication, text conversion is done at lowest level */ static void _qq_send_packet_buddy_auth(GaimConnection *gc, guint32 uid, const gchar response, const gchar *text) { - gchar *text_qq, *uid_str; + gchar *text_qq, uid_str[11]; guint8 bar, *cursor, *raw_data; g_return_if_fail(gc != NULL && uid != 0); - uid_str = g_strdup_printf("%d", uid); + g_snprintf(uid_str, sizeof(uid_str), "%d", uid); bar = 0x1f; raw_data = g_newa(guint8, QQ_MSG_IM_MAX); cursor = raw_data; @@ -132,7 +129,6 @@ } qq_send_cmd(gc, QQ_CMD_BUDDY_AUTH, TRUE, 0, TRUE, raw_data, cursor - raw_data); - g_free(uid_str); } static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid *g, const gchar *text)
--- a/libgaim/protocols/qq/group_search.c Mon Sep 11 01:57:20 2006 +0000 +++ b/libgaim/protocols/qq/group_search.c Mon Sep 11 02:02:18 2006 +0000 @@ -64,28 +64,22 @@ static void _qq_setup_roomlist(qq_data *qd, qq_group *group) { GaimRoomlistRoom *room; - gchar *field; + gchar field[11]; room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, group->group_name_utf8, NULL); - field = g_strdup_printf("%d", group->external_group_id); + g_snprintf(field, sizeof(field), "%d", group->external_group_id); gaim_roomlist_room_add_field(qd->roomlist, room, field); - g_free(field); - field = g_strdup_printf("%d", group->creator_uid); + g_snprintf(field, sizeof(field), "%d", group->creator_uid); gaim_roomlist_room_add_field(qd->roomlist, room, field); - g_free(field); gaim_roomlist_room_add_field(qd->roomlist, room, group->group_desc_utf8); - field = g_strdup_printf("%d", group->internal_group_id); + g_snprintf(field, sizeof(field), "%d", group->internal_group_id); gaim_roomlist_room_add_field(qd->roomlist, room, field); - g_free(field); - field = g_strdup_printf("%d", group->group_type); + g_snprintf(field, sizeof(field), "%d", group->group_type); gaim_roomlist_room_add_field(qd->roomlist, room, field); - g_free(field); - field = g_strdup_printf("%d", group->auth_type); + g_snprintf(field, sizeof(field), "%d", group->auth_type); gaim_roomlist_room_add_field(qd->roomlist, room, field); - g_free(field); - field = g_strdup_printf("%d", group->group_category); + g_snprintf(field, sizeof(field), "%d", group->group_category); gaim_roomlist_room_add_field(qd->roomlist, room, field); - g_free(field); gaim_roomlist_room_add_field(qd->roomlist, room, group->group_name_utf8); gaim_roomlist_room_add(qd->roomlist, room);