comparison src/channel.c @ 9723:80ac9cf77c9b v7.4.2137

commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 1 15:40:54 2016 +0200 patch 7.4.2137 Problem: Using function() with a name will find another function when it is redefined. Solution: Add funcref(). Refer to lambda using a partial. Fix several reference counting issues.
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Aug 2016 15:45:07 +0200
parents b74515b8f3d4
children 9560a2eb7968
comparison
equal deleted inserted replaced
9722:1557241fd3a7 9723:80ac9cf77c9b
1122 { 1122 {
1123 free_callback(*cbp, *pp); 1123 free_callback(*cbp, *pp);
1124 if (callback != NULL && *callback != NUL) 1124 if (callback != NULL && *callback != NUL)
1125 { 1125 {
1126 if (partial != NULL) 1126 if (partial != NULL)
1127 *cbp = partial->pt_name; 1127 *cbp = partial_name(partial);
1128 else 1128 else
1129 {
1129 *cbp = vim_strsave(callback); 1130 *cbp = vim_strsave(callback);
1131 func_ref(*cbp);
1132 }
1130 } 1133 }
1131 else 1134 else
1132 *cbp = NULL; 1135 *cbp = NULL;
1133 *pp = partial; 1136 *pp = partial;
1134 if (*pp != NULL) 1137 if (partial != NULL)
1135 ++(*pp)->pt_refcount; 1138 ++partial->pt_refcount;
1136 } 1139 }
1137 1140
1138 /* 1141 /*
1139 * Set various properties from an "opt" argument. 1142 * Set various properties from an "opt" argument.
1140 */ 1143 */
1277 { 1280 {
1278 ++partial->pt_refcount; 1281 ++partial->pt_refcount;
1279 item->cq_callback = callback; 1282 item->cq_callback = callback;
1280 } 1283 }
1281 else 1284 else
1285 {
1282 item->cq_callback = vim_strsave(callback); 1286 item->cq_callback = vim_strsave(callback);
1287 func_ref(item->cq_callback);
1288 }
1283 item->cq_seq_nr = id; 1289 item->cq_seq_nr = id;
1284 item->cq_prev = head->cq_prev; 1290 item->cq_prev = head->cq_prev;
1285 head->cq_prev = item; 1291 head->cq_prev = item;
1286 item->cq_next = NULL; 1292 item->cq_next = NULL;
1287 if (item->cq_prev == NULL) 1293 if (item->cq_prev == NULL)
3921 void 3927 void
3922 free_job_options(jobopt_T *opt) 3928 free_job_options(jobopt_T *opt)
3923 { 3929 {
3924 if (opt->jo_partial != NULL) 3930 if (opt->jo_partial != NULL)
3925 partial_unref(opt->jo_partial); 3931 partial_unref(opt->jo_partial);
3932 else if (opt->jo_callback != NULL)
3933 func_unref(opt->jo_callback);
3926 if (opt->jo_out_partial != NULL) 3934 if (opt->jo_out_partial != NULL)
3927 partial_unref(opt->jo_out_partial); 3935 partial_unref(opt->jo_out_partial);
3936 else if (opt->jo_out_cb != NULL)
3937 func_unref(opt->jo_out_cb);
3928 if (opt->jo_err_partial != NULL) 3938 if (opt->jo_err_partial != NULL)
3929 partial_unref(opt->jo_err_partial); 3939 partial_unref(opt->jo_err_partial);
3940 else if (opt->jo_err_cb != NULL)
3941 func_unref(opt->jo_err_cb);
3930 if (opt->jo_close_partial != NULL) 3942 if (opt->jo_close_partial != NULL)
3931 partial_unref(opt->jo_close_partial); 3943 partial_unref(opt->jo_close_partial);
3944 else if (opt->jo_close_cb != NULL)
3945 func_unref(opt->jo_close_cb);
3932 if (opt->jo_exit_partial != NULL) 3946 if (opt->jo_exit_partial != NULL)
3933 partial_unref(opt->jo_exit_partial); 3947 partial_unref(opt->jo_exit_partial);
3948 else if (opt->jo_exit_cb != NULL)
3949 func_unref(opt->jo_exit_cb);
3934 } 3950 }
3935 3951
3936 /* 3952 /*
3937 * Get the PART_ number from the first character of an option name. 3953 * Get the PART_ number from the first character of an option name.
3938 */ 3954 */
4474 { 4490 {
4475 job->jv_exit_cb = opt->jo_exit_cb; 4491 job->jv_exit_cb = opt->jo_exit_cb;
4476 ++job->jv_exit_partial->pt_refcount; 4492 ++job->jv_exit_partial->pt_refcount;
4477 } 4493 }
4478 else 4494 else
4495 {
4479 job->jv_exit_cb = vim_strsave(opt->jo_exit_cb); 4496 job->jv_exit_cb = vim_strsave(opt->jo_exit_cb);
4497 func_ref(job->jv_exit_cb);
4498 }
4480 } 4499 }
4481 } 4500 }
4482 } 4501 }
4483 4502
4484 /* 4503 /*