[mutter] monitor-manager: Expose a few helpers to clear structs
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-manager: Expose a few helpers to clear structs
- Date: Fri, 30 Oct 2015 17:16:35 +0000 (UTC)
commit bff75b64be3da88385173520c4f517693f02971c
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Oct 27 15:02:43 2015 +0100
monitor-manager: Expose a few helpers to clear structs
These are useful for child classes to unwind cleanly when constructing
their structures.
https://bugzilla.gnome.org/show_bug.cgi?id=756796
src/backends/meta-monitor-manager-private.h | 4 ++
src/backends/meta-monitor-manager.c | 62 +++++++++++++++++---------
2 files changed, 44 insertions(+), 22 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index c30e8d7..1b80299 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -414,6 +414,10 @@ gint meta_monitor_manager_get_monitor_at_point (MetaMonitorManager
gfloat x,
gfloat y);
+void meta_monitor_manager_clear_output (MetaOutput *output);
+void meta_monitor_manager_clear_mode (MetaMonitorMode *mode);
+void meta_monitor_manager_clear_crtc (MetaCRTC *crtc);
+
/* Returns true if transform causes width and height to be inverted
This is true for the odd transforms in the enum */
static inline gboolean
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index a15673e..38ccc72 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -346,6 +346,23 @@ meta_monitor_manager_constructed (GObject *object)
manager->in_init = FALSE;
}
+void
+meta_monitor_manager_clear_output (MetaOutput *output)
+{
+ g_free (output->name);
+ g_free (output->vendor);
+ g_free (output->product);
+ g_free (output->serial);
+ g_free (output->modes);
+ g_free (output->possible_crtcs);
+ g_free (output->possible_clones);
+
+ if (output->driver_notify)
+ output->driver_notify (output);
+
+ memset (output, 0, sizeof (*output));
+}
+
static void
meta_monitor_manager_free_output_array (MetaOutput *old_outputs,
int n_old_outputs)
@@ -353,22 +370,22 @@ meta_monitor_manager_free_output_array (MetaOutput *old_outputs,
int i;
for (i = 0; i < n_old_outputs; i++)
- {
- g_free (old_outputs[i].name);
- g_free (old_outputs[i].vendor);
- g_free (old_outputs[i].product);
- g_free (old_outputs[i].serial);
- g_free (old_outputs[i].modes);
- g_free (old_outputs[i].possible_crtcs);
- g_free (old_outputs[i].possible_clones);
-
- if (old_outputs[i].driver_notify)
- old_outputs[i].driver_notify (&old_outputs[i]);
- }
+ meta_monitor_manager_clear_output (&old_outputs[i]);
g_free (old_outputs);
}
+void
+meta_monitor_manager_clear_mode (MetaMonitorMode *mode)
+{
+ g_free (mode->name);
+
+ if (mode->driver_notify)
+ mode->driver_notify (mode);
+
+ memset (mode, 0, sizeof (*mode));
+}
+
static void
meta_monitor_manager_free_mode_array (MetaMonitorMode *old_modes,
int n_old_modes)
@@ -376,16 +393,20 @@ meta_monitor_manager_free_mode_array (MetaMonitorMode *old_modes,
int i;
for (i = 0; i < n_old_modes; i++)
- {
- g_free (old_modes[i].name);
-
- if (old_modes[i].driver_notify)
- old_modes[i].driver_notify (&old_modes[i]);
- }
+ meta_monitor_manager_clear_mode (&old_modes[i]);
g_free (old_modes);
}
+void
+meta_monitor_manager_clear_crtc (MetaCRTC *crtc)
+{
+ if (crtc->driver_notify)
+ crtc->driver_notify (crtc);
+
+ memset (crtc, 0, sizeof (*crtc));
+}
+
static void
meta_monitor_manager_free_crtc_array (MetaCRTC *old_crtcs,
int n_old_crtcs)
@@ -393,10 +414,7 @@ meta_monitor_manager_free_crtc_array (MetaCRTC *old_crtcs,
int i;
for (i = 0; i < n_old_crtcs; i++)
- {
- if (old_crtcs[i].driver_notify)
- old_crtcs[i].driver_notify (&old_crtcs[i]);
- }
+ meta_monitor_manager_clear_crtc (&old_crtcs[i]);
g_free (old_crtcs);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]