History

various: use talloc_replace

Kacper Michajłow committed 2 years ago

Commit 5edc8971 parent 3edbd306 files · +10 −21Browse files

Unified · Split

6 files
  1. input/input.c +1 −2
  2. options/m_option.c +2 −4
  3. player/osd.c +3 −6
  4. video/out/vo_gpu_next.c +2 −4
  5. video/out/wayland_common.c +1 −3
  6. video/out/x11_common.c +1 −2
input/input.c+1−2
@@ -1304,8 +1304,7 @@ void mp_input_define_section(struct input_ctx *ictx, char *name, char *location, · 1303 unmodified lines
1304 if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&1304 if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
1305 !bstr_equals0(bs->section, "default"))1305 !bstr_equals0(bs->section, "default"))
1306 {1306 {
1307 talloc_free(bs->owner);1307 talloc_replace(bs, bs->owner, owner);
1308 bs->owner = talloc_strdup(bs, owner);
1309 }1308 }
1310 remove_binds(bs, builtin);1309 remove_binds(bs, builtin);
1311 if (contents && contents[0]) {1310 if (contents && contents[0]) {
options/m_option.c+2−4
@@ -1233,10 +1233,8 @@ static char *print_str(const m_option_t *opt, const void *val) · 1232 unmodified lines
1233 1233
1234static void copy_str(const m_option_t *opt, void *dst, const void *src)1234static void copy_str(const m_option_t *opt, void *dst, const void *src)
1235{1235{
1236 if (dst && src) {1236 if (dst && src)
1237 talloc_free(VAL(dst));1237 talloc_replace(NULL, VAL(dst), VAL(src));
1238 VAL(dst) = talloc_strdup(NULL, VAL(src));
1239 }
1240}1238}
1241 1239
1242static int str_set(const m_option_t *opt, void *dst, struct mpv_node *src)1240static int str_set(const m_option_t *opt, void *dst, struct mpv_node *src)
player/osd.c+3−6
@@ -116,8 +116,7 @@ void term_osd_set_subs(struct MPContext *mpctx, const char *text) · 115 unmodified lines
116 text = ""; // disable116 text = ""; // disable
117 if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)117 if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
118 return;118 return;
119 talloc_free(mpctx->term_osd_subs);119 talloc_replace(mpctx, mpctx->term_osd_subs, text);
120 mpctx->term_osd_subs = talloc_strdup(mpctx, text);
121 term_osd_update(mpctx);120 term_osd_update(mpctx);
122}121}
123 122
@@ -126,14 +125,12 @@ static void term_osd_set_text_lazy(struct MPContext *mpctx, const char *text) · 2 unmodified lines
126 bool video_osd = mpctx->video_out && mpctx->opts->video_osd;125 bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
127 if ((video_osd && mpctx->opts->term_osd != 1) || !text)126 if ((video_osd && mpctx->opts->term_osd != 1) || !text)
128 text = ""; // disable127 text = ""; // disable
129 talloc_free(mpctx->term_osd_text);128 talloc_replace(mpctx, mpctx->term_osd_text, text);
130 mpctx->term_osd_text = talloc_strdup(mpctx, text);
131}129}
132 130
133static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)131static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)
134{132{
135 talloc_free(mpctx->term_osd_status);133 talloc_replace(mpctx, mpctx->term_osd_status, text);
136 mpctx->term_osd_status = talloc_strdup(mpctx, text);
137}134}
138 135
139static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)136static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
video/out/vo_gpu_next.c+2−4
@@ -2028,8 +2028,7 @@ static void update_icc_opts(struct priv *p, const struct mp_icc_opts *opts) · 2027 unmodified lines
2028 update_icc(p, icc);2028 update_icc(p, icc);
2029 2029
2030 // Update cached path2030 // Update cached path
2031 talloc_free(p->icc_path);2031 talloc_replace(p, p->icc_path, opts->profile);
2032 p->icc_path = talloc_strdup(p, opts->profile);
2033}2032}
2034 2033
2035static void update_lut(struct priv *p, struct user_lut *lut)2034static 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) · 9 unmodified lines
2045 2044
2046 // Update cached path2045 // Update cached path
2047 pl_lut_free(&lut->lut);2046 pl_lut_free(&lut->lut);
2048 talloc_free(lut->path);2047 talloc_replace(p, lut->path, lut->opt);
2049 lut->path = talloc_strdup(p, lut->opt);
2050 2048
2051 // Load LUT file2049 // Load LUT file
2052 char *fname = mp_get_user_path(NULL, p->global, lut->path);2050 char *fname = mp_get_user_path(NULL, p->global, lut->path);
video/out/wayland_common.c+1−3
@@ -655,9 +655,7 @@ static void data_offer_handle_offer(void *data, struct wl_data_offer *offer, · 654 unmodified lines
655 int score = mp_event_get_mime_type_score(wl->vo->input_ctx, mime_type);655 int score = mp_event_get_mime_type_score(wl->vo->input_ctx, mime_type);
656 if (score > wl->dnd_mime_score && wl->opts->drag_and_drop != -2) {656 if (score > wl->dnd_mime_score && wl->opts->drag_and_drop != -2) {
657 wl->dnd_mime_score = score;657 wl->dnd_mime_score = score;
658 if (wl->dnd_mime_type)658 talloc_replace(wl, wl->dnd_mime_type, mime_type);
659 talloc_free(wl->dnd_mime_type);
660 wl->dnd_mime_type = talloc_strdup(wl, mime_type);
661 MP_VERBOSE(wl, "Given DND offer with mime type %s\n", wl->dnd_mime_type);659 MP_VERBOSE(wl, "Given DND offer with mime type %s\n", wl->dnd_mime_type);
662 }660 }
663}661}
video/out/x11_common.c+1−2
@@ -2229,8 +2229,7 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) · 2228 unmodified lines
2229 set_screensaver(x11, true);2229 set_screensaver(x11, true);
2230 return VO_TRUE;2230 return VO_TRUE;
2231 case VOCTRL_UPDATE_WINDOW_TITLE:2231 case VOCTRL_UPDATE_WINDOW_TITLE:
2232 talloc_free(x11->window_title);2232 talloc_replace(x11, x11->window_title, (char *)arg);
2233 x11->window_title = talloc_strdup(x11, (char *)arg);
2234 if (!x11->parent || x11->opts->x11_wid_title)2233 if (!x11->parent || x11->opts->x11_wid_title)
2235 vo_x11_update_window_title(vo);2234 vo_x11_update_window_title(vo);
2236 return VO_TRUE;2235 return VO_TRUE;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t