summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-01 15:40:54 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-01 15:40:54 +0200
commit437bafe4c8a83ed71ee006eda7f54b65a90f0d4c (patch)
treedac9426b1bafe44f050bbb13c027de31117c089d /src/channel.c
parent580164481924ed8611eb79f0247a0eb1ca0b3b9a (diff)
patch 7.4.2137v7.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.
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/channel.c b/src/channel.c
index 3b8b5afa05..5ee05e3332 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1124,15 +1124,18 @@ set_callback(
if (callback != NULL && *callback != NUL)
{
if (partial != NULL)
- *cbp = partial->pt_name;
+ *cbp = partial_name(partial);
else
+ {
*cbp = vim_strsave(callback);
+ func_ref(*cbp);
+ }
}
else
*cbp = NULL;
*pp = partial;
- if (*pp != NULL)
- ++(*pp)->pt_refcount;
+ if (partial != NULL)
+ ++partial->pt_refcount;
}
/*
@@ -1279,7 +1282,10 @@ channel_set_req_callback(
item->cq_callback = callback;
}
else
+ {
item->cq_callback = vim_strsave(callback);
+ func_ref(item->cq_callback);
+ }
item->cq_seq_nr = id;
item->cq_prev = head->cq_prev;
head->cq_prev = item;
@@ -3923,14 +3929,24 @@ free_job_options(jobopt_T *opt)
{
if (opt->jo_partial != NULL)
partial_unref(opt->jo_partial);
+ else if (opt->jo_callback != NULL)
+ func_unref(opt->jo_callback);
if (opt->jo_out_partial != NULL)
partial_unref(opt->jo_out_partial);
+ else if (opt->jo_out_cb != NULL)
+ func_unref(opt->jo_out_cb);
if (opt->jo_err_partial != NULL)
partial_unref(opt->jo_err_partial);
+ else if (opt->jo_err_cb != NULL)
+ func_unref(opt->jo_err_cb);
if (opt->jo_close_partial != NULL)
partial_unref(opt->jo_close_partial);
+ else if (opt->jo_close_cb != NULL)
+ func_unref(opt->jo_close_cb);
if (opt->jo_exit_partial != NULL)
partial_unref(opt->jo_exit_partial);
+ else if (opt->jo_exit_cb != NULL)
+ func_unref(opt->jo_exit_cb);
}
/*
@@ -4476,7 +4492,10 @@ job_set_options(job_T *job, jobopt_T *opt)
++job->jv_exit_partial->pt_refcount;
}
else
+ {
job->jv_exit_cb = vim_strsave(opt->jo_exit_cb);
+ func_ref(job->jv_exit_cb);
+ }
}
}
}