diff options
author | Richard Hughes <richard@hughsie.com> | 2009-09-11 16:04:38 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2009-09-11 16:14:24 +0100 |
commit | 59357d79f3d37b11bc2e0f29940d0a0c4fa414a5 (patch) | |
tree | 5ab21da89f23e9dcf85d2b506f7096baf00fe28d | |
parent | b8dd8ffe1ee96ed1afa9cfffdab1bf38d4bd1f05 (diff) |
Use g_ptr_array_new_with_free_func() in more places to make client applications easier
-rw-r--r-- | devkit-power-gobject/Makefile.am | 4 | ||||
-rw-r--r-- | devkit-power-gobject/dkp-device.c | 7 | ||||
-rw-r--r-- | devkit-power-gobject/dkp-wakeups.c | 2 | ||||
-rw-r--r-- | src/dkp-daemon.c | 5 | ||||
-rw-r--r-- | src/dkp-device-list.c | 2 | ||||
-rw-r--r-- | src/dkp-device.c | 3 | ||||
-rw-r--r-- | src/dkp-qos.c | 2 | ||||
-rw-r--r-- | src/dkp-wakeups.c | 18 |
8 files changed, 20 insertions, 23 deletions
diff --git a/devkit-power-gobject/Makefile.am b/devkit-power-gobject/Makefile.am index 588ebce..7068604 100644 --- a/devkit-power-gobject/Makefile.am +++ b/devkit-power-gobject/Makefile.am @@ -55,6 +55,10 @@ libdevkit_power_gobject_la_LDFLAGS = \ -no-undefined \ -export-symbols-regex '^dkp_.*' +libdevkit_power_gobject_la_CFLAGS = \ + $(WARNINGFLAGS_C) \ + $(NULL) + EXTRA_DIST = \ dkp-version.h.in diff --git a/devkit-power-gobject/dkp-device.c b/devkit-power-gobject/dkp-device.c index 0c4910c..06dcf78 100644 --- a/devkit-power-gobject/dkp-device.c +++ b/devkit-power-gobject/dkp-device.c @@ -336,8 +336,7 @@ dkp_device_print_history (const DkpDevice *device, const gchar *type) obj = (const DkpHistoryObj *) g_ptr_array_index (array, i); g_print (" %i\t%.3f\t%s\n", obj->time, obj->value, dkp_device_state_to_text (obj->state)); } - g_ptr_array_foreach (array, (GFunc) dkp_history_obj_free, NULL); - g_ptr_array_free (array, TRUE); + g_ptr_array_unref (array); ret = TRUE; out: return ret; @@ -506,7 +505,7 @@ out: /** * dkp_device_get_history: * - * Returns an array of %DkpHistoryObj's + * Returns an array of %DkpHistoryObj's, free with g_ptr_array_unref() **/ GPtrArray * dkp_device_get_history (const DkpDevice *device, const gchar *type, guint timespec, guint resolution, GError **error) @@ -555,7 +554,7 @@ dkp_device_get_history (const DkpDevice *device, const gchar *type, guint timesp } /* convert */ - array = g_ptr_array_new (); + array = g_ptr_array_new_with_free_func ((GDestroyNotify) dkp_history_obj_free); for (i=0; i<gvalue_ptr_array->len; i++) { gva = (GValueArray *) g_ptr_array_index (gvalue_ptr_array, i); diff --git a/devkit-power-gobject/dkp-wakeups.c b/devkit-power-gobject/dkp-wakeups.c index d524359..77d43cc 100644 --- a/devkit-power-gobject/dkp-wakeups.c +++ b/devkit-power-gobject/dkp-wakeups.c @@ -163,7 +163,7 @@ dkp_wakeups_get_data (DkpWakeups *wakeups, GError **error) } out: if (gvalue_ptr_array != NULL) - g_ptr_array_free (gvalue_ptr_array, TRUE); + g_ptr_array_unref (gvalue_ptr_array); return array; } diff --git a/src/dkp-daemon.c b/src/dkp-daemon.c index 08c1128..e5efac5 100644 --- a/src/dkp-daemon.c +++ b/src/dkp-daemon.c @@ -354,7 +354,7 @@ dkp_daemon_enumerate_devices (DkpDaemon *daemon, DBusGMethodInvocation *context) DkpDevice *device; /* build a pointer array of the object paths */ - object_paths = g_ptr_array_new (); + object_paths = g_ptr_array_new_with_free_func (g_free); array = dkp_device_list_get_array (daemon->priv->power_devices); for (i=0; i<array->len; i++) { device = (DkpDevice *) g_ptr_array_index (array, i); @@ -366,8 +366,7 @@ dkp_daemon_enumerate_devices (DkpDaemon *daemon, DBusGMethodInvocation *context) dbus_g_method_return (context, object_paths); /* free */ - g_ptr_array_foreach (object_paths, (GFunc) g_free, NULL); - g_ptr_array_free (object_paths, TRUE); + g_ptr_array_unref (object_paths); return TRUE; } diff --git a/src/dkp-device-list.c b/src/dkp-device-list.c index 4b31c38..74956f5 100644 --- a/src/dkp-device-list.c +++ b/src/dkp-device-list.c @@ -182,7 +182,7 @@ dkp_device_list_finalize (GObject *object) list = DKP_DEVICE_LIST (object); - g_ptr_array_free (list->priv->array, TRUE); + g_ptr_array_unref (list->priv->array); g_hash_table_unref (list->priv->map_native_path_to_device); G_OBJECT_CLASS (dkp_device_list_parent_class)->finalize (object); diff --git a/src/dkp-device.c b/src/dkp-device.c index 758c164..1a43ee9 100644 --- a/src/dkp-device.c +++ b/src/dkp-device.c @@ -711,8 +711,7 @@ dkp_device_get_history (DkpDevice *device, const gchar *type_string, guint times dbus_g_method_return (context, complex); out: if (array != NULL) { - g_ptr_array_foreach (array, (GFunc) dkp_history_obj_free, NULL); - g_ptr_array_free (array, TRUE); + g_ptr_array_unref (array); } return TRUE; } diff --git a/src/dkp-qos.c b/src/dkp-qos.c index 35b2ce0..6a0f652 100644 --- a/src/dkp-qos.c +++ b/src/dkp-qos.c @@ -479,7 +479,7 @@ dkp_qos_get_latency_requests (DkpQos *qos, GPtrArray **requests, GError **error) // dbus_g_method_return (context, requests); // g_ptr_array_foreach (*requests, (GFunc) g_value_array_free, NULL); -// g_ptr_array_free (*requests, TRUE); +// g_ptr_array_unref (*requests); return TRUE; } diff --git a/src/dkp-wakeups.c b/src/dkp-wakeups.c index 397fd84..3d44aaa 100644 --- a/src/dkp-wakeups.c +++ b/src/dkp-wakeups.c @@ -233,7 +233,7 @@ dkp_wakeups_get_data (DkpWakeups *wakeups, GPtrArray **data, GError **error) // dbus_g_method_return (context, data); // g_ptr_array_foreach (*data, (GFunc) g_value_array_free, NULL); -// g_ptr_array_free (*data, TRUE); +// g_ptr_array_unref (*data); return TRUE; } @@ -267,7 +267,7 @@ dkp_strsplit_complete_set (const gchar *string, const gchar *delimiters, guint m GPtrArray *array; /* find sections not delimited by space */ - array = g_ptr_array_new (); + array = g_ptr_array_new_with_free_func (g_free); for (i=0; string[i] != '\0'; i++) { ret = dkp_is_in (string[i], delimiters); if (ret) { @@ -366,8 +366,7 @@ dkp_wakeups_poll_kernel_cb (DkpWakeups *wakeups) /* find out how many processors we have */ sections = dkp_strsplit_complete_set (lines[0], " ", 0); cpus = sections->len; - g_ptr_array_foreach (sections, (GFunc) g_free, NULL); - g_ptr_array_free (sections, TRUE); + g_ptr_array_unref (sections); /* get the data from " 9: 29730 365 IO-APIC-fasteoi acpi" */ for (i=1; lines[i] != NULL; i++) { @@ -440,8 +439,7 @@ dkp_wakeups_poll_kernel_cb (DkpWakeups *wakeups) obj->value = (interrupts - obj->old) / (gfloat) DKP_WAKEUPS_POLL_INTERVAL_KERNEL; obj->old = interrupts; skip: - g_ptr_array_foreach (sections, (GFunc) g_free, NULL); - g_ptr_array_free (sections, TRUE); + g_ptr_array_unref (sections); } /* tell GUI we've changed */ @@ -557,8 +555,7 @@ dkp_wakeups_poll_userspace_cb (DkpWakeups *wakeups) /* we report this in minutes, not seconds */ obj->value = (gfloat) interrupts / interval; skip: - g_ptr_array_foreach (sections, (GFunc) g_free, NULL); - g_ptr_array_free (sections, TRUE); + g_ptr_array_unref (sections); } @@ -720,7 +717,7 @@ dkp_wakeups_init (DkpWakeups *wakeups) GError *error = NULL; wakeups->priv = DKP_WAKEUPS_GET_PRIVATE (wakeups); - wakeups->priv->data = g_ptr_array_new (); + wakeups->priv->data = g_ptr_array_new_with_free_func ((GDestroyNotify) dkp_wakeups_obj_free); wakeups->priv->total_old = 0; wakeups->priv->total_ave = 0; wakeups->priv->poll_userspace_id = 0; @@ -762,8 +759,7 @@ dkp_wakeups_finalize (GObject *object) /* stop timerstats */ dkp_wakeups_timerstats_disable (wakeups); - g_ptr_array_foreach (wakeups->priv->data, (GFunc) dkp_wakeups_obj_free, NULL); - g_ptr_array_free (wakeups->priv->data, TRUE); + g_ptr_array_unref (wakeups->priv->data); G_OBJECT_CLASS (dkp_wakeups_parent_class)->finalize (object); } |