summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/tags.c22
-rw-r--r--common/tags.h3
2 files changed, 18 insertions, 7 deletions
diff --git a/common/tags.c b/common/tags.c
index ffedab9b24..f7e85ace3d 100644
--- a/common/tags.c
+++ b/common/tags.c
@@ -83,19 +83,27 @@ 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]);
- }
+ mp_tags_replace(new, tags);
return new;
}
+void mp_tags_replace(struct mp_tags *dst, struct mp_tags *src)
+{
+ mp_tags_clear(dst);
+ MP_RESIZE_ARRAY(dst, dst->keys, src->num_keys);
+ MP_RESIZE_ARRAY(dst, dst->values, src->num_keys);
+ dst->num_keys = src->num_keys;
+ for (int n = 0; n < src->num_keys; n++) {
+ dst->keys[n] = talloc_strdup(dst, src->keys[n]);
+ dst->values[n] = talloc_strdup(dst, src->values[n]);
+ }
+}
+
// Return a copy of the tags, but containing only keys in list. Also forces
// the order and casing of the keys (for cosmetic reasons).
// A trailing '*' matches the rest.
diff --git a/common/tags.h b/common/tags.h
index 3e538e7b76..beb8388df1 100644
--- a/common/tags.h
+++ b/common/tags.h
@@ -1,6 +1,8 @@
#ifndef MP_TAGS_H
#define MP_TAGS_H
+#include <stdint.h>
+
#include "misc/bstr.h"
struct mp_tags {
@@ -17,6 +19,7 @@ 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_replace(struct mp_tags *dst, struct mp_tags *src);
struct mp_tags *mp_tags_filtered(void *tparent, struct mp_tags *tags, char **list);
void mp_tags_merge(struct mp_tags *tags, struct mp_tags *src);
struct AVDictionary;