14192
|
1 /**
|
15025
|
2 * @file group_free.c
|
14192
|
3 *
|
15025
|
4 * gaim
|
14192
|
5 *
|
15025
|
6 * Gaim is the legal property of its developers, whose names are too numerous
|
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
8 * source distribution.
|
14192
|
9 *
|
|
10 * This program is free software; you can redistribute it and/or modify
|
|
11 * it under the terms of the GNU General Public License as published by
|
|
12 * the Free Software Foundation; either version 2 of the License, or
|
|
13 * (at your option) any later version.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this program; if not, write to the Free Software
|
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
23 */
|
|
24
|
|
25 #include "debug.h"
|
|
26
|
|
27 #include "buddy_status.h"
|
|
28 #include "group_free.h"
|
|
29 #include "group_network.h"
|
|
30
|
|
31 /* gracefully free all members in a group */
|
14404
|
32 static void qq_group_free_member(qq_group *group)
|
14192
|
33 {
|
|
34 gint i;
|
|
35 GList *list;
|
|
36 qq_buddy *member;
|
|
37
|
|
38 g_return_if_fail(group != NULL);
|
|
39 i = 0;
|
|
40 while (NULL != (list = group->members)) {
|
|
41 member = (qq_buddy *) list->data;
|
|
42 i++;
|
|
43 group->members = g_list_remove(group->members, member);
|
|
44 g_free(member->nickname);
|
|
45 g_free(member);
|
|
46 }
|
|
47
|
|
48 group->members = NULL;
|
|
49 }
|
|
50
|
|
51 /* gracefully free the memory for one qq_group */
|
14404
|
52 void qq_group_free(qq_group *group)
|
14192
|
53 {
|
|
54 g_return_if_fail(group != NULL);
|
14404
|
55 qq_group_free_member(group);
|
14192
|
56 g_free(group->group_name_utf8);
|
|
57 g_free(group->group_desc_utf8);
|
|
58 g_free(group);
|
|
59 }
|
|
60
|
|
61 /* clean up group_packets and free all contents */
|
|
62 void qq_group_packets_free(qq_data *qd)
|
|
63 {
|
|
64 group_packet *p;
|
|
65 gint i;
|
|
66
|
|
67 i = 0;
|
|
68 while (qd->group_packets != NULL) {
|
|
69 p = (group_packet *) (qd->group_packets->data);
|
|
70 qd->group_packets = g_list_remove(qd->group_packets, p);
|
|
71 g_free(p);
|
|
72 i++;
|
|
73 }
|
|
74 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d group packets are freed!\n", i);
|
|
75 }
|
|
76
|
|
77 void qq_group_free_all(qq_data *qd)
|
|
78 {
|
|
79 qq_group *group;
|
|
80 gint i;
|
|
81 g_return_if_fail(qd != NULL);
|
|
82
|
|
83 i = 0;
|
|
84 while (qd->groups != NULL) {
|
|
85 i++;
|
|
86 group = (qq_group *) qd->groups->data;
|
|
87 qd->groups = g_list_remove(qd->groups, group);
|
14404
|
88 qq_group_free(group);
|
14192
|
89 }
|
|
90
|
|
91 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d groups are freed\n", i);
|
|
92 }
|