comparison libpurple/protocols/msn/oim.c @ 22808:f62a4a7fe365

Fix a number of leaks. As far as I can tell, MSNP14 now logs in without leaking.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 03 May 2008 23:51:43 +0000
parents 7d3b2c023ad8
children 9b7af052fd6a
comparison
equal deleted inserted replaced
22807:0b11895cc564 22808:f62a4a7fe365
56 { 56 {
57 MsnOim *oim; 57 MsnOim *oim;
58 58
59 oim = g_new0(MsnOim, 1); 59 oim = g_new0(MsnOim, 1);
60 oim->session = session; 60 oim->session = session;
61 oim->oim_list = NULL; 61 oim->oim_list = NULL;
62 oim->run_id = rand_guid(); 62 oim->run_id = rand_guid();
63 oim->challenge = NULL; 63 oim->challenge = NULL;
64 oim->send_queue = g_queue_new(); 64 oim->send_queue = g_queue_new();
65 oim->send_seq = 1; 65 oim->send_seq = 1;
66 return oim; 66 return oim;
69 /*destroy the oim object*/ 69 /*destroy the oim object*/
70 void 70 void
71 msn_oim_destroy(MsnOim *oim) 71 msn_oim_destroy(MsnOim *oim)
72 { 72 {
73 MsnOimSendReq *request; 73 MsnOimSendReq *request;
74 74
75 purple_debug_info("OIM","destroy the OIM \n"); 75 purple_debug_info("OIM", "destroy the OIM %p\n", oim);
76 g_free(oim->run_id); 76 g_free(oim->run_id);
77 g_free(oim->challenge); 77 g_free(oim->challenge);
78 78
79 while((request = g_queue_pop_head(oim->send_queue)) != NULL){ 79 while((request = g_queue_pop_head(oim->send_queue)) != NULL){
80 msn_oim_free_send_req(request); 80 msn_oim_free_send_req(request);
81 } 81 }
82
82 g_queue_free(oim->send_queue); 83 g_queue_free(oim->send_queue);
83 84 g_list_free(oim->oim_list);
85
84 g_free(oim); 86 g_free(oim);
85 } 87 }
86 88
87 static MsnOimSendReq * 89 static MsnOimSendReq *
88 msn_oim_new_send_req(const char *from_member, const char*friendname, 90 msn_oim_new_send_req(const char *from_member, const char*friendname,
89 const char* to_member, const char *msg) 91 const char* to_member, const char *msg)
90 { 92 {
91 MsnOimSendReq *request; 93 MsnOimSendReq *request;
92 94
93 request = g_new0(MsnOimSendReq, 1); 95 request = g_new0(MsnOimSendReq, 1);
94 request->from_member =g_strdup(from_member); 96 request->from_member = g_strdup(from_member);
95 request->friendname = g_strdup(friendname); 97 request->friendname = g_strdup(friendname);
96 request->to_member = g_strdup(to_member); 98 request->to_member = g_strdup(to_member);
97 request->oim_msg = g_strdup(msg); 99 request->oim_msg = g_strdup(msg);
98 return request; 100 return request;
99 } 101 }
470 { 472 {
471 xmlnode *node, *mNode; 473 xmlnode *node, *mNode;
472 xmlnode *iu_node; 474 xmlnode *iu_node;
473 MsnSession *session = oim->session; 475 MsnSession *session = oim->session;
474 476
475 purple_debug_info("MSNP14:OIM", "%s", xmlmsg); 477 purple_debug_info("MSNP14:OIM", "%s\n", xmlmsg);
476 478
477 node = xmlnode_from_str(xmlmsg, -1); 479 node = xmlnode_from_str(xmlmsg, -1);
478 if (strcmp(node->name, "MD") != 0) { 480 if (strcmp(node->name, "MD") != 0) {
479 purple_debug_info("msnoim", "WTF is this? %s\n", xmlmsg); 481 purple_debug_info("msnoim", "WTF is this? %s\n", xmlmsg);
480 xmlnode_free(node); 482 xmlnode_free(node);