[PATCH] Implement add_resource_simple using add_resource
- From: Jens Georg <mail jensge org>
- To: gupnp-list gnome org
- Subject: [PATCH] Implement add_resource_simple using add_resource
- Date: Fri, 27 May 2011 10:17:10 +0200
Remove duplicate code
---
libgssdp/gssdp-resource-group.c | 43 +++++---------------------------------
1 files changed, 6 insertions(+), 37 deletions(-)
diff --git a/libgssdp/gssdp-resource-group.c b/libgssdp/gssdp-resource-group.c
index 6407c01..5104c1d 100644
--- a/libgssdp/gssdp-resource-group.c
+++ b/libgssdp/gssdp-resource-group.c
@@ -645,46 +645,15 @@ gssdp_resource_group_add_resource_simple (GSSDPResourceGroup *resource_group,
const char *usn,
const char *location)
{
- Resource *resource;
- GError *error;
-
- g_return_val_if_fail (GSSDP_IS_RESOURCE_GROUP (resource_group), 0);
- g_return_val_if_fail (target != NULL, 0);
- g_return_val_if_fail (usn != NULL, 0);
- g_return_val_if_fail (location != NULL, 0);
-
- resource = g_slice_new0 (Resource);
-
- resource->resource_group = resource_group;
-
- resource->target = g_strdup (target);
- resource->usn = g_strdup (usn);
-
- error = NULL;
- resource->target_regex = create_target_regex (target, &error);
- if (error) {
- g_warning ("Error compiling regular expression for '%s': %s",
- target,
- error->message);
-
- g_error_free (error);
- resource_free (resource);
-
- return 0;
- }
+ GList *locations = NULL;
+ guint resource_id;
- resource->locations = g_list_append (resource->locations,
- g_strdup (location));
+ locations = g_list_append (locations, (gpointer) location);
+ resource_id = gssdp_resource_group_add_resource (resource_group, target, usn, locations);
- resource_group->priv->resources =
- g_list_prepend (resource_group->priv->resources, resource);
-
- resource->id = ++resource_group->priv->last_resource_id;
+ g_list_free (locations);
- if (resource_group->priv->available)
- resource_alive (resource);
-
- return resource->id;
+ return resource_id;
}
/**
--
1.7.5.2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]