summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-16 22:40:12 +0200
committerwm4 <wm4@nowhere>2014-07-16 22:40:12 +0200
commit69a8f08f3e7cc0a9121c7fdb3499081fb2e34ddf (patch)
tree22336c48b5cf4f2b61f43f9e5cadf594b3baa345
parent073b2becfe009262356a56e9369f34d842a43b4c (diff)
downloadmpv-69a8f08f3e7cc0a9121c7fdb3499081fb2e34ddf.tar.bz2
mpv-69a8f08f3e7cc0a9121c7fdb3499081fb2e34ddf.tar.xz
tags: add copy function
-rw-r--r--common/tags.c13
-rw-r--r--common/tags.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/common/tags.c b/common/tags.c
index 03765272df..c722d5d89c 100644
--- a/common/tags.c
+++ b/common/tags.c
@@ -61,6 +61,19 @@ void mp_tags_clear(struct mp_tags *tags)
talloc_free_children(tags);
}
+struct mp_tags *mp_tags_dup(void *tparent, struct mp_tags *tags)
+{
+ struct mp_tags *new = talloc_zero(tparent, struct mp_tags);
+ MP_RESIZE_ARRAY(new, new->keys, tags->num_keys);
+ MP_RESIZE_ARRAY(new, new->values, tags->num_keys);
+ new->num_keys = tags->num_keys;
+ for (int n = 0; n < tags->num_keys; n++) {
+ new->keys[n] = talloc_strdup(new, tags->keys[n]);
+ new->values[n] = talloc_strdup(new, tags->values[n]);
+ }
+ return new;
+}
+
void mp_tags_merge(struct mp_tags *tags, struct mp_tags *src)
{
for (int n = 0; n < src->num_keys; n++)
diff --git a/common/tags.h b/common/tags.h
index 4b7bcfa791..375289695f 100644
--- a/common/tags.h
+++ b/common/tags.h
@@ -14,6 +14,7 @@ void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value);
char *mp_tags_get_str(struct mp_tags *tags, const char *key);
char *mp_tags_get_bstr(struct mp_tags *tags, bstr key);
void mp_tags_clear(struct mp_tags *tags);
+struct mp_tags *mp_tags_dup(void *tparent, struct mp_tags *tags);
void mp_tags_merge(struct mp_tags *tags, struct mp_tags *src);
struct AVDictionary;
void mp_tags_copy_from_av_dictionary(struct mp_tags *tags,