0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 11:32:22 +02:00

various: use talloc_replace

This commit is contained in:
Kacper Michajłow 2024-09-05 22:14:28 +02:00
parent 3edbd30798
commit 5edc8973eb
6 changed files with 10 additions and 21 deletions

View File

@ -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)) &&
!bstr_equals0(bs->section, "default"))
{
talloc_free(bs->owner);
bs->owner = talloc_strdup(bs, owner);
talloc_replace(bs, bs->owner, owner);
}
remove_binds(bs, builtin);
if (contents && contents[0]) {

View File

@ -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)
{
if (dst && src) {
talloc_free(VAL(dst));
VAL(dst) = talloc_strdup(NULL, VAL(src));
}
if (dst && src)
talloc_replace(NULL, VAL(dst), VAL(src));
}
static int str_set(const m_option_t *opt, void *dst, struct mpv_node *src)

View File

@ -116,8 +116,7 @@ void term_osd_set_subs(struct MPContext *mpctx, const char *text)
text = ""; // disable
if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
return;
talloc_free(mpctx->term_osd_subs);
mpctx->term_osd_subs = talloc_strdup(mpctx, text);
talloc_replace(mpctx, mpctx->term_osd_subs, text);
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;
if ((video_osd && mpctx->opts->term_osd != 1) || !text)
text = ""; // disable
talloc_free(mpctx->term_osd_text);
mpctx->term_osd_text = talloc_strdup(mpctx, text);
talloc_replace(mpctx, mpctx->term_osd_text, text);
}
static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)
{
talloc_free(mpctx->term_osd_status);
mpctx->term_osd_status = talloc_strdup(mpctx, text);
talloc_replace(mpctx, mpctx->term_osd_status, text);
}
static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)

View File

@ -2028,8 +2028,7 @@ static void update_icc_opts(struct priv *p, const struct mp_icc_opts *opts)
update_icc(p, icc);
// Update cached path
talloc_free(p->icc_path);
p->icc_path = talloc_strdup(p, opts->profile);
talloc_replace(p, p->icc_path, opts->profile);
}
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
pl_lut_free(&lut->lut);
talloc_free(lut->path);
lut->path = talloc_strdup(p, lut->opt);
talloc_replace(p, lut->path, lut->opt);
// Load LUT file
char *fname = mp_get_user_path(NULL, p->global, lut->path);

View File

@ -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);
if (score > wl->dnd_mime_score && wl->opts->drag_and_drop != -2) {
wl->dnd_mime_score = score;
if (wl->dnd_mime_type)
talloc_free(wl->dnd_mime_type);
wl->dnd_mime_type = talloc_strdup(wl, mime_type);
talloc_replace(wl, wl->dnd_mime_type, mime_type);
MP_VERBOSE(wl, "Given DND offer with mime type %s\n", wl->dnd_mime_type);
}
}

View File

@ -2229,8 +2229,7 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
set_screensaver(x11, true);
return VO_TRUE;
case VOCTRL_UPDATE_WINDOW_TITLE:
talloc_free(x11->window_title);
x11->window_title = talloc_strdup(x11, (char *)arg);
talloc_replace(x11, x11->window_title, (char *)arg);
if (!x11->parent || x11->opts->x11_wid_title)
vo_x11_update_window_title(vo);
return VO_TRUE;