mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-19 19:42:24 +02:00
various: use talloc_replace
This commit is contained in:
parent
3edbd30798
commit
5edc8973eb
@ -1304,8 +1304,7 @@ void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,
|
|||||||
if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
|
if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
|
||||||
!bstr_equals0(bs->section, "default"))
|
!bstr_equals0(bs->section, "default"))
|
||||||
{
|
{
|
||||||
talloc_free(bs->owner);
|
talloc_replace(bs, bs->owner, owner);
|
||||||
bs->owner = talloc_strdup(bs, owner);
|
|
||||||
}
|
}
|
||||||
remove_binds(bs, builtin);
|
remove_binds(bs, builtin);
|
||||||
if (contents && contents[0]) {
|
if (contents && contents[0]) {
|
||||||
|
@ -1233,10 +1233,8 @@ static char *print_str(const m_option_t *opt, const void *val)
|
|||||||
|
|
||||||
static void copy_str(const m_option_t *opt, void *dst, const void *src)
|
static void copy_str(const m_option_t *opt, void *dst, const void *src)
|
||||||
{
|
{
|
||||||
if (dst && src) {
|
if (dst && src)
|
||||||
talloc_free(VAL(dst));
|
talloc_replace(NULL, VAL(dst), VAL(src));
|
||||||
VAL(dst) = talloc_strdup(NULL, VAL(src));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int str_set(const m_option_t *opt, void *dst, struct mpv_node *src)
|
static int str_set(const m_option_t *opt, void *dst, struct mpv_node *src)
|
||||||
|
@ -116,8 +116,7 @@ void term_osd_set_subs(struct MPContext *mpctx, const char *text)
|
|||||||
text = ""; // disable
|
text = ""; // disable
|
||||||
if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
|
if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
|
||||||
return;
|
return;
|
||||||
talloc_free(mpctx->term_osd_subs);
|
talloc_replace(mpctx, mpctx->term_osd_subs, text);
|
||||||
mpctx->term_osd_subs = talloc_strdup(mpctx, text);
|
|
||||||
term_osd_update(mpctx);
|
term_osd_update(mpctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,14 +125,12 @@ static void term_osd_set_text_lazy(struct MPContext *mpctx, const char *text)
|
|||||||
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
|
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
|
||||||
if ((video_osd && mpctx->opts->term_osd != 1) || !text)
|
if ((video_osd && mpctx->opts->term_osd != 1) || !text)
|
||||||
text = ""; // disable
|
text = ""; // disable
|
||||||
talloc_free(mpctx->term_osd_text);
|
talloc_replace(mpctx, mpctx->term_osd_text, text);
|
||||||
mpctx->term_osd_text = talloc_strdup(mpctx, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)
|
static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)
|
||||||
{
|
{
|
||||||
talloc_free(mpctx->term_osd_status);
|
talloc_replace(mpctx, mpctx->term_osd_status, text);
|
||||||
mpctx->term_osd_status = talloc_strdup(mpctx, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
|
static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
|
||||||
|
@ -2028,8 +2028,7 @@ static void update_icc_opts(struct priv *p, const struct mp_icc_opts *opts)
|
|||||||
update_icc(p, icc);
|
update_icc(p, icc);
|
||||||
|
|
||||||
// Update cached path
|
// Update cached path
|
||||||
talloc_free(p->icc_path);
|
talloc_replace(p, p->icc_path, opts->profile);
|
||||||
p->icc_path = talloc_strdup(p, opts->profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_lut(struct priv *p, struct user_lut *lut)
|
static void update_lut(struct priv *p, struct user_lut *lut)
|
||||||
@ -2045,8 +2044,7 @@ static void update_lut(struct priv *p, struct user_lut *lut)
|
|||||||
|
|
||||||
// Update cached path
|
// Update cached path
|
||||||
pl_lut_free(&lut->lut);
|
pl_lut_free(&lut->lut);
|
||||||
talloc_free(lut->path);
|
talloc_replace(p, lut->path, lut->opt);
|
||||||
lut->path = talloc_strdup(p, lut->opt);
|
|
||||||
|
|
||||||
// Load LUT file
|
// Load LUT file
|
||||||
char *fname = mp_get_user_path(NULL, p->global, lut->path);
|
char *fname = mp_get_user_path(NULL, p->global, lut->path);
|
||||||
|
@ -655,9 +655,7 @@ static void data_offer_handle_offer(void *data, struct wl_data_offer *offer,
|
|||||||
int score = mp_event_get_mime_type_score(wl->vo->input_ctx, mime_type);
|
int score = mp_event_get_mime_type_score(wl->vo->input_ctx, mime_type);
|
||||||
if (score > wl->dnd_mime_score && wl->opts->drag_and_drop != -2) {
|
if (score > wl->dnd_mime_score && wl->opts->drag_and_drop != -2) {
|
||||||
wl->dnd_mime_score = score;
|
wl->dnd_mime_score = score;
|
||||||
if (wl->dnd_mime_type)
|
talloc_replace(wl, wl->dnd_mime_type, mime_type);
|
||||||
talloc_free(wl->dnd_mime_type);
|
|
||||||
wl->dnd_mime_type = talloc_strdup(wl, mime_type);
|
|
||||||
MP_VERBOSE(wl, "Given DND offer with mime type %s\n", wl->dnd_mime_type);
|
MP_VERBOSE(wl, "Given DND offer with mime type %s\n", wl->dnd_mime_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2229,8 +2229,7 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
|||||||
set_screensaver(x11, true);
|
set_screensaver(x11, true);
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
case VOCTRL_UPDATE_WINDOW_TITLE:
|
case VOCTRL_UPDATE_WINDOW_TITLE:
|
||||||
talloc_free(x11->window_title);
|
talloc_replace(x11, x11->window_title, (char *)arg);
|
||||||
x11->window_title = talloc_strdup(x11, (char *)arg);
|
|
||||||
if (!x11->parent || x11->opts->x11_wid_title)
|
if (!x11->parent || x11->opts->x11_wid_title)
|
||||||
vo_x11_update_window_title(vo);
|
vo_x11_update_window_title(vo);
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user