[gnome-color-manager] Load the introspection file at startup and free the XML data early
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Load the introspection file at startup and free the XML data early
- Date: Tue, 26 Apr 2011 13:55:45 +0000 (UTC)
commit d08d60819a9fcdf3c24c9779834202d8216835b5
Author: Richard Hughes <richard hughsie com>
Date: Tue Apr 26 14:55:32 2011 +0100
Load the introspection file at startup and free the XML data early
This saves a few hundred K of unused private memory when running.
src/gcm-session.c | 48 +++++++++++++++++++++++++++++++++---------------
1 files changed, 33 insertions(+), 15 deletions(-)
---
diff --git a/src/gcm-session.c b/src/gcm-session.c
index f4a4c50..c6a3e02 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -1648,6 +1648,38 @@ out:
}
/**
+ * gcm_session_load_introspection:
+ **/
+static gboolean
+gcm_session_load_introspection (GcmSessionPrivate *priv,
+ GError **error)
+{
+ gboolean ret;
+ gchar *introspection_data = NULL;
+ GFile *file = NULL;
+
+ /* load introspection from file */
+ file = g_file_new_for_path (DATADIR "/dbus-1/interfaces/org.gnome.ColorManager.xml");
+ ret = g_file_load_contents (file, NULL, &introspection_data,
+ NULL, NULL, error);
+ if (!ret)
+ goto out;
+
+ /* build introspection from XML */
+ priv->introspection = g_dbus_node_info_new_for_xml (introspection_data,
+ error);
+ if (priv->introspection == NULL) {
+ ret = FALSE;
+ goto out;
+ }
+out:
+ if (file != NULL)
+ g_object_unref (file);
+ g_free (introspection_data);
+ return ret;
+}
+
+/**
* main:
**/
int
@@ -1655,9 +1687,7 @@ main (int argc, char *argv[])
{
gboolean login = FALSE;
gboolean ret;
- gchar *introspection_data = NULL;
GError *error = NULL;
- GFile *file = NULL;
GOptionContext *context;
guint owner_id = 0;
guint poll_id = 0;
@@ -1752,22 +1782,13 @@ main (int argc, char *argv[])
priv->loop = g_main_loop_new (NULL, FALSE);
/* load introspection from file */
- file = g_file_new_for_path (DATADIR "/dbus-1/interfaces/org.gnome.ColorManager.xml");
- ret = g_file_load_contents (file, NULL, &introspection_data, NULL, NULL, &error);
+ ret = gcm_session_load_introspection (priv, &error);
if (!ret) {
g_warning ("failed to load introspection: %s", error->message);
g_error_free (error);
goto out;
}
- /* build introspection from XML */
- priv->introspection = g_dbus_node_info_new_for_xml (introspection_data, &error);
- if (priv->introspection == NULL) {
- g_warning ("failed to load introspection: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
/* own the object */
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
GCM_DBUS_SERVICE,
@@ -1783,11 +1804,8 @@ main (int argc, char *argv[])
/* success */
retval = 0;
out:
- g_free (introspection_data);
if (poll_id != 0)
g_source_remove (poll_id);
- if (file != NULL)
- g_object_unref (file);
if (owner_id > 0)
g_bus_unown_name (owner_id);
if (priv != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]