comparison libpurple/protocols/yahoo/yahoo_friend.c @ 22807:0b11895cc564

Leak fixes. Avoid creating an unnecessary parallel data structure to YahooFriend.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 03 May 2008 21:03:13 +0000
parents 44b4e8bd759b
children f16aba67b685
comparison
equal deleted inserted replaced
22806:f15d9ded0c45 22807:0b11895cc564
74 return f; 74 return f;
75 } 75 }
76 76
77 void yahoo_friend_set_ip(YahooFriend *f, const char *ip) 77 void yahoo_friend_set_ip(YahooFriend *f, const char *ip)
78 { 78 {
79 if (f->ip) 79 g_free(f->ip);
80 g_free(f->ip);
81 f->ip = g_strdup(ip); 80 f->ip = g_strdup(ip);
82 } 81 }
83 82
84 const char *yahoo_friend_get_ip(YahooFriend *f) 83 const char *yahoo_friend_get_ip(YahooFriend *f)
85 { 84 {
86 return f->ip; 85 return f->ip;
87 } 86 }
88 87
89 void yahoo_friend_set_game(YahooFriend *f, const char *game) 88 void yahoo_friend_set_game(YahooFriend *f, const char *game)
90 { 89 {
91 if (f->game) 90 g_free(f->game);
92 g_free(f->game);
93 91
94 if (game) 92 if (game)
95 f->game = g_strdup(game); 93 f->game = g_strdup(game);
96 else 94 else
97 f->game = NULL; 95 f->game = NULL;
102 return f->game; 100 return f->game;
103 } 101 }
104 102
105 void yahoo_friend_set_status_message(YahooFriend *f, char *msg) 103 void yahoo_friend_set_status_message(YahooFriend *f, char *msg)
106 { 104 {
107 if (f->msg) 105 g_free(f->msg);
108 g_free(f->msg);
109 106
110 f->msg = msg; 107 f->msg = msg;
111 } 108 }
112 109
113 const char *yahoo_friend_get_status_message(YahooFriend *f) 110 const char *yahoo_friend_get_status_message(YahooFriend *f)
123 gboolean yahoo_friend_get_buddy_icon_need_request(YahooFriend *f) 120 gboolean yahoo_friend_get_buddy_icon_need_request(YahooFriend *f)
124 { 121 {
125 return !f->bicon_sent_request; 122 return !f->bicon_sent_request;
126 } 123 }
127 124
125 void yahoo_friend_set_alias_id(YahooFriend *f, const char *alias_id)
126 {
127 g_free(f->alias_id);
128 f->alias_id = g_strdup(alias_id);
129 }
130
131 const char *yahoo_friend_get_alias_id(YahooFriend *f)
132 {
133 return f->alias_id;
134 }
135
128 void yahoo_friend_free(gpointer p) 136 void yahoo_friend_free(gpointer p)
129 { 137 {
130 YahooFriend *f = p; 138 YahooFriend *f = p;
131 if (f->msg) 139 g_free(f->msg);
132 g_free(f->msg); 140 g_free(f->game);
133 if (f->game) 141 g_free(f->ip);
134 g_free(f->game); 142 g_free(f->alias_id);
135 if (f->ip)
136 g_free(f->ip);
137 g_free(f); 143 g_free(f);
138 } 144 }
139 145
140 void yahoo_process_presence(PurpleConnection *gc, struct yahoo_packet *pkt) 146 void yahoo_process_presence(PurpleConnection *gc, struct yahoo_packet *pkt)
141 { 147 {