summaryrefslogtreecommitdiffstats
path: root/src/structs.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-03 15:38:16 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-03 15:38:16 +0200
commitf7779c63d4fe531e2483502d4441f24802342768 (patch)
tree1d630be90ef6aa51ec11ce5eac248dcd92acb041 /src/structs.h
parent5adc55cb746893c6ddf7865ff654582902dee2e3 (diff)
patch 8.2.0684: Vim9: memory leak when using lambdav8.2.0684
Problem: Vim9: memory leak when using lambda. Solution: Move the funccal context to the partial. Free the function when exiting.
Diffstat (limited to 'src/structs.h')
-rw-r--r--src/structs.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/structs.h b/src/structs.h
index 601194e12f..7fd325a825 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1777,6 +1777,21 @@ typedef struct {
typval_T *basetv; // base for base->method()
} funcexe_T;
+/*
+ * Structure to hold the context of a compiled function, used by closures
+ * defined in that function.
+ */
+typedef struct funcstack_S
+{
+ garray_T fs_ga; // contains the stack, with:
+ // - arguments
+ // - frame
+ // - local variables
+
+ int fs_refcount; // nr of closures referencing this funcstack
+ int fs_copyID; // for garray_T collection
+} funcstack_T;
+
struct partial_S
{
int pt_refcount; // reference count
@@ -1786,8 +1801,16 @@ struct partial_S
// with pt_name
int pt_auto; // when TRUE the partial was created for using
// dict.member in handle_subscript()
+
+ // For a compiled closure: the arguments and local variables.
+ garray_T *pt_ectx_stack; // where to find local vars
+ int pt_ectx_frame; // index of function frame in uf_ectx_stack
+ funcstack_T *pt_funcstack; // copy of stack, used after context
+ // function returns
+
int pt_argc; // number of arguments
typval_T *pt_argv; // arguments in allocated array
+
dict_T *pt_dict; // dict for "self"
};