[PATCH 1/2] device: add priv pointer to private instance data



https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00072.html
---
This is what I would like to do...

 src/devices/nm-device.c | 8 +++++---
 src/devices/nm-device.h | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index fb892be..8949279 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -81,7 +81,7 @@ static void impl_device_delete     (NMDevice *self, DBusGMethodInvocation *conte
 
 G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, G_TYPE_OBJECT)
 
-#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
+#define NM_DEVICE_GET_PRIVATE(o) (((NMDevice *) o)->priv)
 
 enum {
        STATE_CHANGED,
@@ -173,7 +173,7 @@ typedef struct {
        int ifindex;
 } DeleteOnDeactivateData;
 
-typedef struct {
+typedef struct _NMDevicePrivate {
        gboolean in_state_changed;
        gboolean initialized;
 
@@ -8367,7 +8367,9 @@ spec_match_list (NMDevice *self, const GSList *specs)
 static void
 nm_device_init (NMDevice *self)
 {
-       NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+       NMDevicePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_DEVICE, NMDevicePrivate);
+
+       self->priv = priv;
 
        priv->type = NM_DEVICE_TYPE_UNKNOWN;
        priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index ad6de87..ab26d6e 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -104,8 +104,11 @@ typedef enum { /*< skip >*/
        NM_DEVICE_CHECK_CON_AVAILABLE_ALL                                   = 
(((__NM_DEVICE_CHECK_CON_AVAILABLE_ALL - 1) << 1) - 1),
 } NMDeviceCheckConAvailableFlags;
 
+struct _NMDevicePrivate;
+
 struct _NMDevice {
        GObject parent;
+       struct _NMDevicePrivate *priv;
 };
 
 /* The flags have an relaxing meaning, that means, specifying more flags, can make
-- 
2.1.0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]