summaryrefslogtreecommitdiff
path: root/metadata
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-06-18 18:43:41 +0200
committerAlexander Larsson <alexl@redhat.com>2009-06-23 15:10:27 +0200
commitdfa3f13abb7d34aa62e2c817b1ddabb448b969f9 (patch)
tree87312bb78e9a5b820f5e72a3928ba35625c3a42a /metadata
parent9a185243a13620b860ba1ed3601a16a6d2f7c3a1 (diff)
downloadgvfs-dfa3f13abb7d34aa62e2c817b1ddabb448b969f9.tar.gz
Add metabuilder_free
Diffstat (limited to 'metadata')
-rw-r--r--metadata/metabuilder.c38
-rw-r--r--metadata/metabuilder.h2
2 files changed, 38 insertions, 2 deletions
diff --git a/metadata/metabuilder.c b/metadata/metabuilder.c
index 85b7a835..8e0fff22 100644
--- a/metadata/metabuilder.c
+++ b/metadata/metabuilder.c
@@ -27,6 +27,14 @@ meta_builder_new (void)
return builder;
}
+void
+meta_builder_free (MetaBuilder *builder)
+{
+ if (builder->root)
+ metafile_free (builder->root);
+ g_free (builder);
+}
+
static gint
compare_metafile (gconstpointer a,
gconstpointer b)
@@ -64,6 +72,32 @@ metafile_new (const char *name,
return f;
}
+static void
+metadata_free (MetaData *data)
+{
+ g_free (data->key);
+ if (data->is_list)
+ {
+ g_list_foreach (data->values, (GFunc)g_free, NULL);
+ g_list_free (data->values);
+ }
+ else
+ g_free (data->value);
+
+ g_free (data);
+}
+
+void
+metafile_free (MetaFile *file)
+{
+ g_free (file->name);
+ g_list_foreach (file->children, (GFunc)metafile_free, NULL);
+ g_list_free (file->children);
+ g_list_foreach (file->data, (GFunc)metadata_free, NULL);
+ g_list_free (file->data);
+ g_free (file);
+}
+
MetaFile *
metafile_lookup_child (MetaFile *metafile,
const char *name,
@@ -351,7 +385,7 @@ metafile_collect_keywords (MetaFile *file,
}
}
-GHashTable *
+static GHashTable *
string_block_begin (void)
{
return g_hash_table_new (g_str_hash, g_str_equal);
@@ -537,7 +571,7 @@ write_metadata (GString *out,
}
}
-gboolean
+static gboolean
write_all_data_and_close (int fd, char *data, gsize len)
{
gsize written;
diff --git a/metadata/metabuilder.h b/metadata/metabuilder.h
index 18f3aba9..ba6e5556 100644
--- a/metadata/metabuilder.h
+++ b/metadata/metabuilder.h
@@ -29,6 +29,7 @@ struct _MetaData {
};
MetaBuilder *meta_builder_new (void);
+void meta_builder_free (MetaBuilder *builder);
void meta_builder_print (MetaBuilder *builder);
MetaFile * meta_builder_lookup (MetaBuilder *builder,
const char *path,
@@ -37,6 +38,7 @@ gboolean meta_builder_write (MetaBuilder *builder,
const char *filename);
MetaFile * metafile_new (const char *name,
MetaFile *parent);
+void metafile_free (MetaFile *file);
MetaFile * metafile_lookup_child (MetaFile *metafile,
const char *name,
gboolean create);