4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Calling a function that waits for input may cause List and
12 Dictionary arguments to be freed by the garbage collector.
13 Solution: Keep a list of all arguments to internal functions.
17 *** ../vim-7.0.081/src/eval.c Sat Sep 2 13:45:01 2006
18 --- src/eval.c Sun Sep 3 15:36:10 2006
25 + * Struct used to make a list of all arguments used in internal functions.
27 + typedef struct av_list_item_S av_list_item_T;
28 + struct av_list_item_S {
29 + av_list_item_T *avl_next;
30 + typval_T *avl_argvars;
33 + av_list_item_T *argvars_list = NULL;
36 * Info used by a ":for" loop.
52 set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID);
55 + /* arguments for internal functions */
56 + for (av = argvars_list; av != NULL; av = av->avl_next)
57 + for (i = 0; av->avl_argvars[i].v_type != VAR_UNKNOWN; ++i)
58 + set_ref_in_item(&av->avl_argvars[i], copyID);
61 * 2. Go through the list of dicts and free items without the copyID.
66 error = ERROR_TOOMANY;
69 + av_list_item_T av_list_item;
71 + /* Add the arguments to the "argvars_list" to avoid the
72 + * garbage collector not seeing them. This isn't needed
73 + * for user functions, because the arguments are available
74 + * in the a: hashtab. */
75 + av_list_item.avl_argvars = argvars;
76 + av_list_item.avl_next = argvars_list;
77 + argvars_list = &av_list_item;
79 argvars[argcount].v_type = VAR_UNKNOWN;
80 functions[i].f_func(argvars, rettv);
83 + argvars_list = av_list_item.avl_next;
87 *** ../vim-7.0.081/src/version.c Sat Sep 2 17:58:36 2006
88 --- src/version.c Sun Sep 3 15:35:16 2006
92 { /* Add new patch number below this line */
98 Just think of all the things we haven't thought of yet.
100 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
101 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
102 \\\ download, build and distribute -- http://www.A-A-P.org ///
103 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///