comparison libpurple/protocols/jabber/xdata.c @ 16065:0db4eca4a3e0

I noticed some places where we were doing the whole "if (!NULL) then free()" thing.
author Mark Doliner <mark@kingant.net>
date Wed, 11 Apr 2007 15:45:48 +0000
parents 32c366eeeb99
children bfa7bc0e7b21
comparison
equal deleted inserted replaced
16064:5106ccf9f9f1 16065:0db4eca4a3e0
198 purple_request_field_string_set_masked(field, TRUE); 198 purple_request_field_string_set_masked(field, TRUE);
199 purple_request_field_group_add_field(group, field); 199 purple_request_field_group_add_field(group, field);
200 200
201 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); 201 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE));
202 202
203 if(value) 203 g_free(value);
204 g_free(value);
205 } else if(!strcmp(type, "text-multi") || !strcmp(type, "jid-multi")) { 204 } else if(!strcmp(type, "text-multi") || !strcmp(type, "jid-multi")) {
206 GString *str = g_string_new(""); 205 GString *str = g_string_new("");
207 206
208 for(valuenode = xmlnode_get_child(fn, "value"); valuenode; 207 for(valuenode = xmlnode_get_child(fn, "value"); valuenode;
209 valuenode = xmlnode_get_next_twin(valuenode)) { 208 valuenode = xmlnode_get_next_twin(valuenode)) {
281 field = purple_request_field_bool_new(var, label, def); 280 field = purple_request_field_bool_new(var, label, def);
282 purple_request_field_group_add_field(group, field); 281 purple_request_field_group_add_field(group, field);
283 282
284 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_BOOLEAN)); 283 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_BOOLEAN));
285 284
286 if(value) 285 g_free(value);
287 g_free(value);
288 } else if(!strcmp(type, "fixed") && value) { 286 } else if(!strcmp(type, "fixed") && value) {
289 if((valuenode = xmlnode_get_child(fn, "value"))) 287 if((valuenode = xmlnode_get_child(fn, "value")))
290 value = xmlnode_get_data(valuenode); 288 value = xmlnode_get_data(valuenode);
291 289
292 field = purple_request_field_label_new("", value); 290 field = purple_request_field_label_new("", value);
293 purple_request_field_group_add_field(group, field); 291 purple_request_field_group_add_field(group, field);
294 292
295 if(value) 293 g_free(value);
296 g_free(value);
297 } else if(!strcmp(type, "hidden")) { 294 } else if(!strcmp(type, "hidden")) {
298 if((valuenode = xmlnode_get_child(fn, "value"))) 295 if((valuenode = xmlnode_get_child(fn, "value")))
299 value = xmlnode_get_data(valuenode); 296 value = xmlnode_get_data(valuenode);
300 297
301 field = purple_request_field_string_new(var, "", value ? value : "", 298 field = purple_request_field_string_new(var, "", value ? value : "",
303 purple_request_field_set_visible(field, FALSE); 300 purple_request_field_set_visible(field, FALSE);
304 purple_request_field_group_add_field(group, field); 301 purple_request_field_group_add_field(group, field);
305 302
306 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); 303 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE));
307 304
308 if(value) 305 g_free(value);
309 g_free(value);
310 } else { /* text-single, jid-single, and the default */ 306 } else { /* text-single, jid-single, and the default */
311 if((valuenode = xmlnode_get_child(fn, "value"))) 307 if((valuenode = xmlnode_get_child(fn, "value")))
312 value = xmlnode_get_data(valuenode); 308 value = xmlnode_get_data(valuenode);
313 309
314 field = purple_request_field_string_new(var, label, 310 field = purple_request_field_string_new(var, label,
320 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_JID_SINGLE)); 316 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_JID_SINGLE));
321 } else { 317 } else {
322 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); 318 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE));
323 } 319 }
324 320
325 if(value) 321 g_free(value);
326 g_free(value);
327 } 322 }
328 } 323 }
329 324
330 if((x = xmlnode_get_child(packet, "title"))) 325 if((x = xmlnode_get_child(packet, "title")))
331 title = xmlnode_get_data(x); 326 title = xmlnode_get_data(x);
335 330
336 handle = purple_request_fields(js->gc, title, title, instructions, fields, 331 handle = purple_request_fields(js->gc, title, title, instructions, fields,
337 _("OK"), G_CALLBACK(jabber_x_data_ok_cb), 332 _("OK"), G_CALLBACK(jabber_x_data_ok_cb),
338 _("Cancel"), G_CALLBACK(jabber_x_data_cancel_cb), data); 333 _("Cancel"), G_CALLBACK(jabber_x_data_cancel_cb), data);
339 334
340 if(title) 335 g_free(title);
341 g_free(title); 336 g_free(instructions);
342 if(instructions)
343 g_free(instructions);
344 337
345 return handle; 338 return handle;
346 } 339 }
347 340
348 341