comparison src/accountopt.c @ 14035:8bda65b88e49

[gaim-migrate @ 16638] A bunch of small changes. Mostly remove "if not null" checks before calling g_free, g_list_free, g_slist_free and g_strdup. Also use g_list_foreach() to call g_free to free strings in an array. And some whitespace changes here and there. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Aug 2006 08:27:39 +0000
parents f09c6e8df82c
children
comparison
equal deleted inserted replaced
14034:0839a7b71325 14035:8bda65b88e49
85 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name); 85 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name);
86 86
87 if (option == NULL) 87 if (option == NULL)
88 return NULL; 88 return NULL;
89 89
90 if (default_value != NULL) 90 option->default_value.string = g_strdup(default_value);
91 option->default_value.string = g_strdup(default_value);
92 91
93 return option; 92 return option;
94 } 93 }
95 94
96 GaimAccountOption * 95 GaimAccountOption *
157 const char *value) 156 const char *value)
158 { 157 {
159 g_return_if_fail(option != NULL); 158 g_return_if_fail(option != NULL);
160 g_return_if_fail(option->type == GAIM_PREF_STRING); 159 g_return_if_fail(option->type == GAIM_PREF_STRING);
161 160
162 if (option->default_value.string != NULL) 161 g_free(option->default_value.string);
163 g_free(option->default_value.string); 162 option->default_value.string = g_strdup(value);
164
165 option->default_value.string = (value == NULL ? NULL : g_strdup(value));
166 } 163 }
167 164
168 void 165 void
169 gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked) 166 gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked)
170 { 167 {
308 305
309 split = g_new0(GaimAccountUserSplit, 1); 306 split = g_new0(GaimAccountUserSplit, 1);
310 307
311 split->text = g_strdup(text); 308 split->text = g_strdup(text);
312 split->field_sep = sep; 309 split->field_sep = sep;
313 split->default_value = (default_value == NULL 310 split->default_value = g_strdup(default_value);
314 ? NULL : g_strdup(default_value));
315 311
316 return split; 312 return split;
317 } 313 }
318 314
319 void 315 void
320 gaim_account_user_split_destroy(GaimAccountUserSplit *split) 316 gaim_account_user_split_destroy(GaimAccountUserSplit *split)
321 { 317 {
322 g_return_if_fail(split != NULL); 318 g_return_if_fail(split != NULL);
323 319
324 if (split->text != NULL) 320 g_free(split->text);
325 g_free(split->text); 321 g_free(split->default_value);
326
327 if (split->default_value != NULL)
328 g_free(split->default_value);
329
330 g_free(split); 322 g_free(split);
331 } 323 }
332 324
333 const char * 325 const char *
334 gaim_account_user_split_get_text(const GaimAccountUserSplit *split) 326 gaim_account_user_split_get_text(const GaimAccountUserSplit *split)