From 2e72a9b262ac71a8a7e8ed9b00efa80597d5f17d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 17 Mar 2010 23:12:21 +0100 Subject: tag: added function tag_merge_replace() Like tag_merge(), but can deal with NULL parameters, and frees both tag objects. --- src/tag.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/tag.c') 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) { -- cgit v1.2.3