summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2014-01-04 16:30:38 +0100
committerAlexander Larsson <alexl@redhat.com>2014-01-20 10:20:06 +0100
commit5de780f7d7ca5ef3d930c050fa6f57c8d3f0ebdf (patch)
tree8592d250dd5016246d96d200ee7d1af538508648 /common
parentafd78d3945e383501e91ebf0a2845a075869a046 (diff)
downloadgvfs-5de780f7d7ca5ef3d930c050fa6f57c8d3f0ebdf.tar.gz
client: remove GVfsUriMountInfo
This structure is too similar to GMountSpec to deserve a presence (it's essentially a GMountSpec with a path). By removing it we can remove some code and avoid wasteful allocations in sensitive paths such as creating and traversing GFiles. https://bugzilla.gnome.org/show_bug.cgi?id=721461
Diffstat (limited to 'common')
-rw-r--r--common/gmountspec.c39
-rw-r--r--common/gmountspec.h3
2 files changed, 33 insertions, 9 deletions
diff --git a/common/gmountspec.c b/common/gmountspec.c
index ac9b66cd..bde37fa1 100644
--- a/common/gmountspec.c
+++ b/common/gmountspec.c
@@ -131,12 +131,12 @@ add_item (GMountSpec *spec,
g_array_append_val (spec->items, item);
}
-
-void
-g_mount_spec_set_with_len (GMountSpec *spec,
- const char *key,
- const char *value,
- int value_len)
+static void
+g_mount_spec_set_with_len_internal (GMountSpec *spec,
+ const char *key,
+ const char *value,
+ int value_len,
+ gboolean copy)
{
int i;
char *value_copy;
@@ -144,10 +144,15 @@ g_mount_spec_set_with_len (GMountSpec *spec,
g_return_if_fail (key != NULL);
g_return_if_fail (value != NULL);
- if (value_len == -1)
- value_copy = g_strdup (value);
+ if (copy)
+ {
+ if (value_len == -1)
+ value_copy = g_strdup (value);
+ else
+ value_copy = g_strndup (value, value_len);
+ }
else
- value_copy = g_strndup (value, value_len);
+ value_copy = (char*) value;
for (i = 0; i < spec->items->len; i++)
{
@@ -165,6 +170,15 @@ g_mount_spec_set_with_len (GMountSpec *spec,
}
void
+g_mount_spec_set_with_len (GMountSpec *spec,
+ const char *key,
+ const char *value,
+ int value_len)
+{
+ g_mount_spec_set_with_len_internal (spec, key, value, value_len, TRUE);
+}
+
+void
g_mount_spec_set (GMountSpec *spec,
const char *key,
const char *value)
@@ -172,6 +186,13 @@ g_mount_spec_set (GMountSpec *spec,
g_mount_spec_set_with_len (spec, key, value, -1);
}
+void
+g_mount_spec_take (GMountSpec *spec,
+ const char *key,
+ char *value)
+{
+ g_mount_spec_set_with_len_internal (spec, key, value, -1, FALSE);
+}
GMountSpec *
g_mount_spec_copy (GMountSpec *spec)
diff --git a/common/gmountspec.h b/common/gmountspec.h
index 143c0946..909079e3 100644
--- a/common/gmountspec.h
+++ b/common/gmountspec.h
@@ -56,6 +56,9 @@ void g_mount_spec_set_mount_prefix (GMountSpec *spec,
void g_mount_spec_set (GMountSpec *spec,
const char *key,
const char *value);
+void g_mount_spec_take (GMountSpec *spec,
+ const char *key,
+ char *value);
void g_mount_spec_set_with_len (GMountSpec *spec,
const char *key,
const char *value,