aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/prefs_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-03-11 23:14:42 +0000
committerGuy Harris <guy@alum.mit.edu>2003-03-11 23:14:42 +0000
commit50899dad380ce3ae6c846368f0e38b7ee3f1ae75 (patch)
treea4f4d0581fac9cfb2f6ee6e7a9f07f2e601f6f38 /gtk/prefs_dlg.c
parent569e74a1f31efc29883fc74485f12a591412817d (diff)
When registering a string preference, if the value of the preference is
NULL, convert it to a copy of a null string, otherwise replace it with a copy of the string, so that we know that the variable for the preference always points to a string that can be freed. That also obviates the need to worry about a null-pointer value for a preference variable when checking to see whether a preference has changed. When checking for a string preference not being set, check for an empty string, not a null pointer - the above code turns null pointers into pointers to empty strings, *and* the GUI code does (and always did!) the same. svn path=/trunk/; revision=7343
Diffstat (limited to 'gtk/prefs_dlg.c')
-rw-r--r--gtk/prefs_dlg.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index e17e8892b1..587db48ac8 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.58 2002/12/27 18:32:55 oabad Exp $
+ * $Id: prefs_dlg.c,v 1.59 2003/03/11 23:14:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -871,10 +871,9 @@ pref_fetch(pref_t *pref, gpointer user_data)
case PREF_STRING:
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
- if (*pref->varp.string == NULL || strcmp(*pref->varp.string, str_val) != 0) {
+ if (strcmp(*pref->varp.string, str_val) != 0) {
*pref_changed_p = TRUE;
- if (*pref->varp.string != NULL)
- g_free(*pref->varp.string);
+ g_free(*pref->varp.string);
*pref->varp.string = g_strdup(str_val);
}
break;
@@ -1151,13 +1150,9 @@ pref_revert(pref_t *pref, gpointer user_data)
break;
case PREF_STRING:
- if (*pref->varp.string != pref->saved_val.string &&
- (*pref->varp.string == NULL ||
- pref->saved_val.string == NULL ||
- strcmp(*pref->varp.string, pref->saved_val.string) != 0)) {
+ if (strcmp(*pref->varp.string, pref->saved_val.string) != 0) {
*pref_changed_p = TRUE;
- if (*pref->varp.string != NULL)
- g_free(*pref->varp.string);
+ g_free(*pref->varp.string);
*pref->varp.string = g_strdup(pref->saved_val.string);
}
break;