Patch 8.2.3753
Problem: Vim9: function unreferenced while called is never deleted.
Solution: Delete a function when no longer referenced.
Files: src/vim9execute.c, src/userfunc.c, src/proto/userfunc.pro
*** ../vim-8.2.3752/src/vim9execute.c 2021-12-05 17:20:20.422818200 +0000
--- src/vim9execute.c 2021-12-06 15:03:55.275657022 +0000
***************
*** 4988,4995 ****
estack_pop();
current_sctx = save_current_sctx;
! // TODO: when is it safe to delete the function if it is no longer used?
! --ufunc->uf_calls;
if (*msg_list != NULL && saved_msg_list != NULL)
{
--- 4988,4996 ----
estack_pop();
current_sctx = save_current_sctx;
! if (--ufunc->uf_calls <= 0 && ufunc->uf_refcount <= 0)
! // Function was unreferenced while being used, free it now.
! func_clear_free(ufunc, FALSE);
if (*msg_list != NULL && saved_msg_list != NULL)
{
*** ../vim-8.2.3752/src/userfunc.c 2021-12-05 22:19:22.840153470 +0000
--- src/userfunc.c 2021-12-06 15:05:47.307568846 +0000
***************
*** 2281,2287 ****
* Free all things that a function contains and free the function itself.
* When "force" is TRUE we are exiting.
*/
! static void
func_clear_free(ufunc_T *fp, int force)
{
func_clear(fp, force);
--- 2281,2287 ----
* Free all things that a function contains and free the function itself.
* When "force" is TRUE we are exiting.
*/
! void
func_clear_free(ufunc_T *fp, int force)
{
func_clear(fp, force);
*** ../vim-8.2.3752/src/proto/userfunc.pro 2021-12-03 11:08:34.260842706
+0000
--- src/proto/userfunc.pro 2021-12-06 15:05:50.679566109 +0000
***************
*** 12,17 ****
--- 12,18 ----
ufunc_T *find_func(char_u *name, int is_global, cctx_T *cctx);
int func_is_global(ufunc_T *ufunc);
int func_name_refcount(char_u *name);
+ void func_clear_free(ufunc_T *fp, int force);
int copy_func(char_u *lambda, char_u *global, ectx_T *ectx);
int funcdepth_increment(void);
void funcdepth_decrement(void);
*** ../vim-8.2.3752/src/version.c 2021-12-06 11:24:05.592240981 +0000
--- src/version.c 2021-12-06 15:05:42.655572620 +0000
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 3753,
/**/
--
It's totally unfair to suggest - as many have - that engineers are socially
inept. Engineers simply have different objectives when it comes to social
interaction.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211206150806.BD4DE1C0BD1%40moolenaar.net.