diff options
author | Jens Georg <mail@jensge.org> | 2012-02-08 22:36:32 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2012-02-13 08:03:03 +0200 |
commit | ed610fd393950d32ee46a937c72c76b0fcb4da80 (patch) | |
tree | 5a7756d8720c354f3898ccce3391734781f79aec | |
parent | 701d1c7116f48e64baa9304241c75fd476621a8d (diff) | |
download | gupnp-vala-ed610fd393950d32ee46a937c72c76b0fcb4da80.tar.gz |
gupnp: Use pointers for Value
gupnp and vala disagree about the memory management of the values;
GUPnP allocates them with g_slice_alloc while vala tries to free them
with g_free, leading to memory corruption.
There's no chance but to take the Values generated by GUPnP out of the
automatic memory management and let the user deal with it.
This patch also adds helper functions to free the data structures.
https://bugzilla.gnome.org/show_bug.cgi?id=669702
-rw-r--r-- | gupnp-1.0/gupnp-1.0-custom.vala | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gupnp-1.0/gupnp-1.0-custom.vala b/gupnp-1.0/gupnp-1.0-custom.vala index 9b687f1..1d9eb91 100644 --- a/gupnp-1.0/gupnp-1.0-custom.vala +++ b/gupnp-1.0/gupnp-1.0-custom.vala @@ -20,18 +20,31 @@ */ namespace GUPnP { - + public static void value_list_free (GLib.List<weak GLib.Value*> list) { + foreach (var v in list) { + v->unset (); + GLib.Slice.free (sizeof (GLib.Value), v); + } + } + + public static void value_hash_free (GLib.HashTable<string, weak GLib.Value*> hash) { + hash.for_each ((k, v) => { + v->unset (); + GLib.Slice.free (sizeof (GLib.Value), v); + }); + } + public class ServiceProxy { [CCode (has_construct_function = false)] public ServiceProxy (); public virtual signal void subscription_lost (GLib.Error reason); - public bool end_action_hash (GUPnP.ServiceProxyAction action, [CCode (pos=-0.9)] GLib.HashTable<string, GLib.Value?> hash) throws GLib.Error; - public bool end_action_list (GUPnP.ServiceProxyAction action, [CCode (pos=-0.9)] GLib.List<string> out_names, [CCode (pos=-0.8)] GLib.List<GLib.Type?> out_types, [CCode (pos=-0.7)] out GLib.List<GLib.Value?> out_values) throws GLib.Error; + public bool end_action_hash (GUPnP.ServiceProxyAction action, [CCode (pos=-0.9)] GLib.HashTable<string, weak GLib.Value*> hash) throws GLib.Error; + public bool end_action_list (GUPnP.ServiceProxyAction action, [CCode (pos=-0.9)] GLib.List<string> out_names, [CCode (pos=-0.8)] GLib.List<GLib.Type?> out_types, [CCode (pos=-0.7)] out GLib.List<weak GLib.Value*> out_values) throws GLib.Error; - public bool send_action_hash (string action, [CCode (pos=-0.9)] GLib.HashTable<string, GLib.Value?> in_hash, [CCode (pos=-0.8)] GLib.HashTable<string, GLib.Value?> out_hash) throws GLib.Error; - public bool send_action_list (string action, [CCode (pos=-0.9)]GLib.List<string> in_names, [CCode (pos=-0.8)]GLib.List<GLib.Value?> in_values, [CCode (pos=-0.7)] GLib.List<string> out_names, [CCode (pos=-0.6)]GLib.List<GLib.Type?> out_types, [CCode (pos=-0.5)] out GLib.List<GLib.Value?> out_values) throws GLib.Error; + public bool send_action_hash (string action, [CCode (pos=-0.9)] GLib.HashTable<string, GLib.Value?> in_hash, [CCode (pos=-0.8)] GLib.HashTable<string, weak GLib.Value*> out_hash) throws GLib.Error; + public bool send_action_list (string action, [CCode (pos=-0.9)] GLib.List<string> in_names, [CCode (pos=-0.8)] GLib.List<weak GLib.Value?> in_values, [CCode (pos=-0.7)] GLib.List<string> out_names, [CCode (pos=-0.6)] GLib.List<GLib.Type?> out_types, [CCode (pos=-0.5)] out GLib.List<weak GLib.Value*> out_values) throws GLib.Error; } public class Service { |