[ekiga] Another slight gmconf api change, doubling as a leak fix
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Another slight gmconf api change, doubling as a leak fix
- Date: Thu, 10 Jun 2010 14:40:08 +0000 (UTC)
commit 770d3872fb9688a6bfde48a09fefd5234e055ba9
Author: Julien Puydt <jpuydt gnome org>
Date: Thu Jun 10 16:01:22 2010 +0200
Another slight gmconf api change, doubling as a leak fix
This "const char*" meant the calling code didn't have to free... which it
should have done!
lib/engine/audioinput/audioinput-gmconf-bridge.cpp | 3 +-
.../audiooutput/audiooutput-gmconf-bridge.cpp | 6 +++-
.../gmconf-personal-details.cpp | 9 +++++--
lib/engine/components/opal/opal-gmconf-bridge.cpp | 21 +++++++++++++------
lib/gmconf/gmconf-gconf.c | 4 +-
lib/gmconf/gmconf-glib.c | 16 ++++++++------
lib/gmconf/gmconf.h | 3 +-
lib/gui/gmconfwidgets.c | 10 +++++++-
8 files changed, 47 insertions(+), 25 deletions(-)
---
diff --git a/lib/engine/audioinput/audioinput-gmconf-bridge.cpp b/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
index fbf392e..4d04f8e 100644
--- a/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
+++ b/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
@@ -62,7 +62,7 @@ void AudioInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry
std::vector <AudioInputDevice> devices;
bool found = false;
- const gchar *value = gm_conf_entry_get_string (entry);
+ gchar* value = gm_conf_entry_get_string (entry);
audioinput_core.get_devices (devices);
if (value != NULL) {
for (std::vector<AudioInputDevice>::iterator it = devices.begin ();
@@ -73,6 +73,7 @@ void AudioInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry
break;
}
}
+ g_free (value);
}
AudioInputDevice device;
diff --git a/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp b/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp
index 0ffd445..f773358 100644
--- a/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp
+++ b/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp
@@ -79,7 +79,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
std::vector <AudioOutputDevice> devices;
bool found = false;
- const gchar *value = gm_conf_entry_get_string (entry);
+ gchar* value = gm_conf_entry_get_string (entry);
audiooutput_core.get_devices (devices);
if (value != NULL) {
for (std::vector<AudioOutputDevice>::iterator it = devices.begin ();
@@ -90,6 +90,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
break;
}
}
+ g_free (value);
}
AudioOutputDevice device;
@@ -115,7 +116,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
PTRACE(4, "AudioOutputCoreConfBridge\tUpdating device");
AudioOutputDevice device;
- const gchar *audio_device = NULL;
+ gchar* audio_device = NULL;
audio_device = gm_conf_entry_get_string (entry);
if (audio_device == NULL) {
@@ -123,6 +124,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
}
else {
device.SetFromString(audio_device);
+ g_free (audio_device);
}
if ( (device.type == "" ) ||
diff --git a/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp b/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
index c8966c0..2242170 100644
--- a/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
+++ b/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
@@ -47,10 +47,11 @@ display_name_changed_nt (G_GNUC_UNUSED gpointer id,
gpointer data)
{
Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
- const gchar* val = gm_conf_entry_get_string (entry);
+ gchar* val = gm_conf_entry_get_string (entry);
if (val != NULL)
details->display_name_changed (val);
+ g_free (val);
}
static void
@@ -59,10 +60,11 @@ presence_changed_nt (G_GNUC_UNUSED gpointer id,
gpointer data)
{
Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
- const gchar* val = gm_conf_entry_get_string (entry);
+ gchar* val = gm_conf_entry_get_string (entry);
if (val != NULL)
details->presence_changed (val);
+ g_free (val);
}
static void
@@ -71,10 +73,11 @@ status_changed_nt (G_GNUC_UNUSED gpointer id,
gpointer data)
{
Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
- const gchar* val = gm_conf_entry_get_string (entry);
+ gchar* val = gm_conf_entry_get_string (entry);
if (val != NULL)
details->status_changed (val);
+ g_free (val);
}
Gmconf::PersonalDetails::PersonalDetails ()
diff --git a/lib/engine/components/opal/opal-gmconf-bridge.cpp b/lib/engine/components/opal/opal-gmconf-bridge.cpp
index 3ebe288..f98a2e3 100644
--- a/lib/engine/components/opal/opal-gmconf-bridge.cpp
+++ b/lib/engine/components/opal/opal-gmconf-bridge.cpp
@@ -168,8 +168,9 @@ void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
//
else if (key == NAT_KEY "stun_server") {
- const char *stun_server = gm_conf_entry_get_string (entry);
+ gchar* stun_server = gm_conf_entry_get_string (entry);
manager.set_stun_server (stun_server ? stun_server : "stun.ekiga.net");
+ g_free (stun_server);
}
else if (key == NAT_KEY "enable_stun") {
@@ -269,9 +270,10 @@ void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
if (key == SIP_KEY "outbound_proxy_host") {
- const gchar *str = gm_conf_entry_get_string (entry);
+ gchar* str = gm_conf_entry_get_string (entry);
if (str != NULL)
sip_manager->set_outbound_proxy (str);
+ g_free (str);
}
else if (key == SIP_KEY "dtmf_mode") {
@@ -279,9 +281,10 @@ void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
}
else if (key == SIP_KEY "forward_host") {
- const gchar *str = gm_conf_entry_get_string (entry);
+ gchar* str = gm_conf_entry_get_string (entry);
if (str != NULL)
sip_manager->set_forward_uri (str);
+ g_free (str);
}
else if (key == SIP_KEY "binding_timeout") {
@@ -317,9 +320,10 @@ void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
}
else if (key == H323_KEY "forward_host") {
- const gchar *str = gm_conf_entry_get_string (entry);
+ gchar* str = gm_conf_entry_get_string (entry);
if (str != NULL)
h323_manager->set_forward_uri (str);
+ g_free (str);
}
}
}
@@ -331,9 +335,10 @@ void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
//
else if (key == PERSONAL_DATA_KEY "full_name") {
- const gchar *str = gm_conf_entry_get_string (entry);
- if (str != NULL)
+ gchar* str = gm_conf_entry_get_string (entry);
+ if (str != NULL)
manager.set_display_name (str);
+ g_free (str);
}
@@ -368,13 +373,15 @@ void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
else if (key == PORTS_KEY "udp_port_range"
|| key == PORTS_KEY "tcp_port_range") {
- const gchar *ports = gm_conf_entry_get_string (entry);
+ gchar* ports = NULL;
gchar **couple = NULL;
unsigned min_port = 0;
unsigned max_port = 0;
+ ports = gm_conf_entry_get_string (entry);
if (ports)
couple = g_strsplit (ports, ":", 2);
+ g_free (ports);
if (couple && couple [0])
min_port = atoi (couple [0]);
diff --git a/lib/gmconf/gmconf-gconf.c b/lib/gmconf/gmconf-gconf.c
index bc2d0a3..ba7d47f 100644
--- a/lib/gmconf/gmconf-gconf.c
+++ b/lib/gmconf/gmconf-gconf.c
@@ -318,7 +318,7 @@ gm_conf_entry_get_int (GmConfEntry *entry)
}
-const gchar *
+gchar *
gm_conf_entry_get_string (GmConfEntry *entry)
{
GConfEntry *gconf_entry = NULL;
@@ -327,7 +327,7 @@ gm_conf_entry_get_string (GmConfEntry *entry)
gconf_entry = (GConfEntry *)entry;
if (gconf_entry->value)
- return gconf_value_get_string (gconf_entry->value);
+ return g_strdup (gconf_value_get_string (gconf_entry->value));
return NULL;
}
diff --git a/lib/gmconf/gmconf-glib.c b/lib/gmconf/gmconf-glib.c
index f306712..453a533 100644
--- a/lib/gmconf/gmconf-glib.c
+++ b/lib/gmconf/gmconf-glib.c
@@ -200,7 +200,7 @@ static void entry_set_bool (GmConfEntry *, const gboolean);
static gint entry_get_int (const GmConfEntry *);
static void entry_set_int (GmConfEntry *, const gint);
-static const gchar *entry_get_string (const GmConfEntry *);
+static gchar *entry_get_string (const GmConfEntry *);
static void entry_set_string (GmConfEntry *, const gchar *);
static GSList *entry_get_list (const GmConfEntry *);
@@ -595,12 +595,12 @@ entry_set_int (GmConfEntry *entry,
entry->value.boolean = val;
}
-static const gchar *
+static gchar*
entry_get_string (const GmConfEntry *entry)
{
check_entry_type_return (entry, GM_CONF_STRING, NULL);
- return entry->value.string;
+ return g_strdup (entry->value.string);
}
static void
@@ -946,9 +946,11 @@ database_save_entry (G_GNUC_UNUSED GQuark quark,
break;
case GM_CONF_STRING:
txt = entry_get_string (entry);
- if (txt != NULL)
+ if (txt != NULL) {
+
value = g_markup_escape_text (txt, -1);
- else
+ g_free (txt);
+ } else
value = g_strdup ("");
break;
case GM_CONF_LIST:
@@ -1252,7 +1254,7 @@ gm_conf_entry_get_int (GmConfEntry *entry)
return entry_get_int (entry);
}
-const gchar *
+gchar *
gm_conf_entry_get_string (GmConfEntry *entry)
{
g_return_val_if_fail (entry != NULL, NULL);
@@ -1361,7 +1363,7 @@ gm_conf_get_string (const gchar *key)
check_entry_for_key_return (entry, key, NULL);
- return g_strdup (entry_get_string (entry));
+ return entry_get_string (entry);
}
void
diff --git a/lib/gmconf/gmconf.h b/lib/gmconf/gmconf.h
index 2eb195c..1077c1c 100644
--- a/lib/gmconf/gmconf.h
+++ b/lib/gmconf/gmconf.h
@@ -94,7 +94,8 @@ GmConfEntryType gm_conf_entry_get_type (GmConfEntry *);
const gchar *gm_conf_entry_get_key (GmConfEntry *);
gboolean gm_conf_entry_get_bool (GmConfEntry *);
gint gm_conf_entry_get_int (GmConfEntry *);
-const gchar *gm_conf_entry_get_string (GmConfEntry *);
+/* Should be freed! */
+gchar *gm_conf_entry_get_string (GmConfEntry *);
/* Should be freed! */
GSList *gm_conf_entry_get_list (GmConfEntry *);
diff --git a/lib/gui/gmconfwidgets.c b/lib/gui/gmconfwidgets.c
index 3454a78..fbac013 100644
--- a/lib/gui/gmconfwidgets.c
+++ b/lib/gui/gmconfwidgets.c
@@ -107,7 +107,7 @@ entry_changed_nt (G_GNUC_UNUSED gpointer cid,
if (gm_conf_entry_get_type(entry) == GM_CONF_STRING) {
e = GTK_WIDGET (data);
- current_value = (gchar *) gm_conf_entry_get_string (entry);
+ current_value = gm_conf_entry_get_string (entry);
if (current_value
&& strcmp (current_value, gtk_entry_get_text (GTK_ENTRY (e)))) {
@@ -134,6 +134,8 @@ entry_changed_nt (G_GNUC_UNUSED gpointer cid,
(gpointer) entry_focus_changed,
NULL);
}
+
+ g_free (current_value);
}
}
@@ -361,6 +363,7 @@ string_option_menu_changed_nt (G_GNUC_UNUSED gpointer cid,
GtkWidget *e = NULL;
gchar *text = NULL;
+ gchar* txt = NULL;
if (gm_conf_entry_get_type (entry) == GM_CONF_STRING) {
@@ -373,11 +376,14 @@ string_option_menu_changed_nt (G_GNUC_UNUSED gpointer cid,
for (cpt = 0 ; cpt < count ; cpt++) {
gtk_tree_model_get (model, &iter, 0, &text, -1);
- if (text && !strcmp (text, gm_conf_entry_get_string (entry))) {
+ txt = gm_conf_entry_get_string (entry);
+ if (text && !strcmp (text, txt)) {
g_free (text);
+ g_free (txt);
break;
}
+ g_free (txt);
gtk_tree_model_iter_next (model, &iter);
g_free (text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]