Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DLNA-RUI
gupnp
Commits
c0fca003
Commit
c0fca003
authored
Jun 24, 2013
by
Olivier Crête
Committed by
Jens Georg
Aug 16, 2013
Browse files
Make NMDevice into a refcounted structure
https://bugzilla.gnome.org/show_bug.cgi?id=694454
parent
78109f17
Changes
1
Hide whitespace changes
Inline
Side-by-side
libgupnp/gupnp-network-manager.c
View file @
c0fca003
...
...
@@ -97,6 +97,8 @@ typedef enum
typedef
struct
{
gint
ref_count
;
GUPnPNetworkManager
*
manager
;
GUPnPContext
*
context
;
...
...
@@ -128,13 +130,25 @@ nm_device_new (GUPnPNetworkManager *manager,
nm_device
->
manager
=
manager
;
nm_device
->
proxy
=
device_proxy
;
g_atomic_int_set
(
&
nm_device
->
ref_count
,
1
);
return
nm_device
;
}
static
NMDevice
*
nm_device_ref
(
NMDevice
*
nm_device
)
{
g_atomic_int_inc
(
&
nm_device
->
ref_count
);
return
nm_device
;
}
static
void
nm_device_
f
re
e
(
NMDevice
*
nm_device
)
nm_device_
un
re
f
(
NMDevice
*
nm_device
)
{
if
(
!
g_atomic_int_dec_and_test
(
&
nm_device
->
ref_count
))
return
;
g_object_unref
(
nm_device
->
proxy
);
if
(
nm_device
->
wifi_proxy
!=
NULL
)
g_object_unref
(
nm_device
->
wifi_proxy
);
...
...
@@ -527,7 +541,7 @@ on_manager_signal (GDBusProxy *proxy,
nm_device
=
(
NMDevice
*
)
device_node
->
data
;
priv
->
nm_devices
=
g_list_remove
(
priv
->
nm_devices
,
nm_device
);
nm_device_
f
re
e
(
nm_device
);
nm_device_
un
re
f
(
nm_device
);
g_free
(
device_path
);
}
}
...
...
@@ -686,7 +700,8 @@ gupnp_network_manager_dispose (GObject *object)
}
if
(
priv
->
nm_devices
!=
NULL
)
{
g_list_foreach
(
priv
->
nm_devices
,
(
GFunc
)
nm_device_free
,
NULL
);
g_list_foreach
(
priv
->
nm_devices
,
(
GFunc
)
nm_device_unref
,
NULL
);
g_list_free
(
priv
->
nm_devices
);
priv
->
nm_devices
=
NULL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment