aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-03-17 23:12:21 +0100
committerMax Kellermann <max@duempel.org>2010-03-17 23:12:21 +0100
commit2e72a9b262ac71a8a7e8ed9b00efa80597d5f17d (patch)
tree1d053e0828b76946b23a57d683dff4b157debae6 /src/tag.c
parent96033e4b4e9ed599d8663a4d2d5a9dd586957bab (diff)
downloadmpd-2e72a9b262ac71a8a7e8ed9b00efa80597d5f17d.tar.gz
mpd-2e72a9b262ac71a8a7e8ed9b00efa80597d5f17d.tar.xz
mpd-2e72a9b262ac71a8a7e8ed9b00efa80597d5f17d.zip
tag: added function tag_merge_replace()
Like tag_merge(), but can deal with NULL parameters, and frees both tag objects.
Diffstat (limited to 'src/tag.c')
-rw-r--r--src/tag.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tag.c b/src/tag.c
index 34205d20d..c34256b78 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -247,6 +247,22 @@ tag_merge(const struct tag *base, const struct tag *add)
return ret;
}
+struct tag *
+tag_merge_replace(struct tag *base, struct tag *add)
+{
+ if (add == NULL)
+ return base;
+
+ if (base == NULL)
+ return add;
+
+ struct tag *tag = tag_merge(base, add);
+ tag_free(base);
+ tag_free(add);
+
+ return tag;
+}
+
const char *
tag_get_value(const struct tag *tag, enum tag_type type)
{