summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-18 10:08:48 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-18 01:42:36 -0800
commit6827901230a962ef40fbc18c6ab25d4d702b95aa (patch)
tree1c56f01ae57c3f1490bd3f79ed25daaafba15f43
parent4d87c700e007d6fbff1d742c0e6e6700451172e2 (diff)
downloadmpv-6827901230a962ef40fbc18c6ab25d4d702b95aa.tar.bz2
mpv-6827901230a962ef40fbc18c6ab25d4d702b95aa.tar.xz
ta: introduce talloc_dup() and use it in some places
It was actually already implemented as ta_dup_ptrtype(), but that seems like a clunky name. Also we still use the talloc_ names throughout the source, and I'd rather use an old name instead of a mixing inconsistent naming conventions.
-rw-r--r--demux/demux.c4
-rw-r--r--demux/demux_mkv.c5
-rw-r--r--input/cmd_parse.c6
-rw-r--r--ta/ta.h4
-rw-r--r--ta/ta_talloc.h1
-rw-r--r--video/out/vo.c4
6 files changed, 12 insertions, 12 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 4ccb03a17d..d621b9d869 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1811,7 +1811,7 @@ static struct replaygain_data *decode_rgain(struct mp_log *log,
rg.album_gain = rg.track_gain;
rg.album_peak = rg.track_peak;
}
- return talloc_memdup(NULL, &rg, sizeof(rg));
+ return talloc_dup(NULL, &rg);
}
if (decode_gain(log, tags, "REPLAYGAIN_GAIN", &rg.track_gain) >= 0 &&
@@ -1819,7 +1819,7 @@ static struct replaygain_data *decode_rgain(struct mp_log *log,
{
rg.album_gain = rg.track_gain;
rg.album_peak = rg.track_peak;
- return talloc_memdup(NULL, &rg, sizeof(rg));
+ return talloc_dup(NULL, &rg);
}
return NULL;
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 6713a13db9..76fc70976f 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -1076,7 +1076,7 @@ static int demux_mkv_read_tags(demuxer_t *demuxer)
if (ebml_read_element(s, &parse_ctx, &tags, &ebml_tags_desc) < 0)
return -1;
- mkv_d->tags = talloc_memdup(mkv_d, &tags, sizeof(tags));
+ mkv_d->tags = talloc_dup(mkv_d, &tags);
talloc_steal(mkv_d->tags, parse_ctx.talloc_ctx);
return 0;
}
@@ -2758,8 +2758,7 @@ static int read_block_group(demuxer_t *demuxer, int64_t end,
&ebml_block_additions_desc) < 0)
return -1;
if (additions.n_block_more > 0) {
- block->additions =
- talloc_memdup(NULL, &additions, sizeof(additions));
+ block->additions = talloc_dup(NULL, &additions);
talloc_steal(block->additions, parse_ctx.talloc_ctx);
parse_ctx.talloc_ctx = NULL;
}
diff --git a/input/cmd_parse.c b/input/cmd_parse.c
index c4ac9dd6b7..c5f428e23d 100644
--- a/input/cmd_parse.c
+++ b/input/cmd_parse.c
@@ -356,7 +356,7 @@ mp_cmd_t *mp_input_parse_cmd_(struct mp_log *log, bstr str, const char *loc)
talloc_steal(list, cmd);
struct mp_cmd_arg arg = {0};
arg.v.p = cmd;
- list->args = talloc_memdup(list, &arg, sizeof(arg));
+ list->args = talloc_dup(list, &arg);
p_prev = &cmd->queue_next;
cmd = list;
}
@@ -406,7 +406,7 @@ mp_cmd_t *mp_cmd_clone(mp_cmd_t *cmd)
if (!cmd)
return NULL;
- ret = talloc_memdup(NULL, cmd, sizeof(mp_cmd_t));
+ ret = talloc_dup(NULL, cmd);
talloc_set_destructor(ret, destroy_cmd);
ret->name = talloc_strdup(ret, cmd->name);
ret->args = talloc_zero_array(ret, struct mp_cmd_arg, ret->nargs);
@@ -427,7 +427,7 @@ mp_cmd_t *mp_cmd_clone(mp_cmd_t *cmd)
} else {
struct mp_cmd_arg arg = {0};
arg.v.p = sub;
- ret->args = talloc_memdup(ret, &arg, sizeof(arg));
+ ret->args = talloc_dup(ret, &arg);
}
prev = sub;
}
diff --git a/ta/ta.h b/ta/ta.h
index 4945aa2be7..18d8caf368 100644
--- a/ta/ta.h
+++ b/ta/ta.h
@@ -96,7 +96,7 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF(
#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
-#define ta_dup_ptrtype(ta_parent, ptr) \
+#define ta_dup(ta_parent, ptr) \
(TA_TYPEOF(ptr))ta_memdup(ta_parent, ptr, sizeof(*(ptr)))
// Ugly macros that crash on OOM.
@@ -126,7 +126,7 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF(
#define ta_xnew_array_size(...) ta_oom_p(ta_new_array_size(__VA_ARGS__))
#define ta_xnew_ptrtype(...) ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
#define ta_xnew_array_ptrtype(...) ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
-#define ta_xdup_ptrtype(...) ta_oom_g(ta_dup_ptrtype(__VA_ARGS__))
+#define ta_xdup(...) ta_oom_g(ta_dup(__VA_ARGS__))
#define ta_xsteal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_xsteal_(ta_parent, ptr)
#define ta_xrealloc(ta_parent, ptr, type, count) \
diff --git a/ta/ta_talloc.h b/ta/ta_talloc.h
index 9ebedd94fd..bde25bc013 100644
--- a/ta/ta_talloc.h
+++ b/ta/ta_talloc.h
@@ -45,6 +45,7 @@
#define talloc_get_size ta_get_size
#define talloc_free_children ta_free_children
#define talloc_free ta_free
+#define talloc_dup ta_xdup
#define talloc_memdup ta_xmemdup
#define talloc_strdup ta_xstrdup
#define talloc_strndup ta_xstrndup
diff --git a/video/out/vo.c b/video/out/vo.c
index 0527d1364c..fa79d51739 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -574,7 +574,7 @@ static void run_reconfig(void *p)
mp_image_params_get_dsize(params, &vo->dwidth, &vo->dheight);
talloc_free(vo->params);
- vo->params = talloc_memdup(vo, params, sizeof(*params));
+ vo->params = talloc_dup(vo, params);
*ret = vo->driver->reconfig(vo, vo->params);
vo->config_ok = *ret >= 0;
@@ -632,7 +632,7 @@ void vo_control_async(struct vo *vo, int request, void *data)
switch (request) {
case VOCTRL_UPDATE_PLAYBACK_STATE:
- d[2] = ta_xdup_ptrtype(d, (struct voctrl_playback_state *)data);
+ d[2] = talloc_dup(d, (struct voctrl_playback_state *)data);
break;
case VOCTRL_KILL_SCREENSAVER:
case VOCTRL_RESTORE_SCREENSAVER: