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
13041304 if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
13051305 !bstr_equals0(bs->section, "default"))
13061306 {
1307− talloc_free(bs->owner);
1308− bs->owner = talloc_strdup(bs, owner);
1307+ talloc_replace(bs, bs->owner, owner);
13091308 }
13101309 remove_binds(bs, builtin);
13111310 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
12331233
12341234 static void copy_str(const m_option_t *opt, void *dst, const void *src)
12351235 {
1236− if (dst && src) {
1237− talloc_free(VAL(dst));
1238− VAL(dst) = talloc_strdup(NULL, VAL(src));
1239− }
1236+ if (dst && src)
1237+ talloc_replace(NULL, VAL(dst), VAL(src));
12401238 }
12411239
12421240 static 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
116116 text = ""; // disable
117117 if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
118118 return;
119− talloc_free(mpctx->term_osd_subs);
120− mpctx->term_osd_subs = talloc_strdup(mpctx, text);
119+ talloc_replace(mpctx, mpctx->term_osd_subs, text);
121120 term_osd_update(mpctx);
122121 }
123122
@@ -126,14 +125,12 @@ static void term_osd_set_text_lazy(struct MPContext *mpctx, const char *text) · 2 unmodified lines
126125 bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
127126 if ((video_osd && mpctx->opts->term_osd != 1) || !text)
128127 text = ""; // disable
129− talloc_free(mpctx->term_osd_text);
130− mpctx->term_osd_text = talloc_strdup(mpctx, text);
128+ talloc_replace(mpctx, mpctx->term_osd_text, text);
131129 }
132130
133131 static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)
134132 {
135− talloc_free(mpctx->term_osd_status);
136− mpctx->term_osd_status = talloc_strdup(mpctx, text);
133+ talloc_replace(mpctx, mpctx->term_osd_status, text);
137134 }
138135
139136 static 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
20282028 update_icc(p, icc);
20292029
20302030 // Update cached path
2031− talloc_free(p->icc_path);
2032− p->icc_path = talloc_strdup(p, opts->profile);
2031+ talloc_replace(p, p->icc_path, opts->profile);
20332032 }
20342033
20352034 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) · 9 unmodified lines
20452044
20462045 // Update cached path
20472046 pl_lut_free(&lut->lut);
2048− talloc_free(lut->path);
2049− lut->path = talloc_strdup(p, lut->opt);
2047+ talloc_replace(p, lut->path, lut->opt);
20502048
20512049 // Load LUT file
20522050 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
655655 int score = mp_event_get_mime_type_score(wl->vo->input_ctx, mime_type);
656656 if (score > wl->dnd_mime_score && wl->opts->drag_and_drop != -2) {
657657 wl->dnd_mime_score = score;
658− if (wl->dnd_mime_type)
659− talloc_free(wl->dnd_mime_type);
660− wl->dnd_mime_type = talloc_strdup(wl, mime_type);
658+ talloc_replace(wl, wl->dnd_mime_type, mime_type);
661659 MP_VERBOSE(wl, "Given DND offer with mime type %s\n", wl->dnd_mime_type);
662660 }
663661 }
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
22292229 set_screensaver(x11, true);
22302230 return VO_TRUE;
22312231 case VOCTRL_UPDATE_WINDOW_TITLE:
2232− talloc_free(x11->window_title);
2233− x11->window_title = talloc_strdup(x11, (char *)arg);
2232+ talloc_replace(x11, x11->window_title, (char *)arg);
22342233 if (!x11->parent || x11->opts->x11_wid_title)
22352234 vo_x11_update_window_title(vo);
22362235 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