From ee645472ebe153e2c6669c84a632297a8110bdb6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 31 Oct 2022 15:06:20 -0300 Subject: Stack reallocation done with a single realloc To avoid the need of both the old and the new stack addresses valid at the same time, to correct the pointers to the stack, these pointers are changed to offsets before the reallocation and then changed back to pointers after the reallocation. --- lobject.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lobject.h') diff --git a/lobject.h b/lobject.h index 7af7bd89..e7f58cbd 100644 --- a/lobject.h +++ b/lobject.h @@ -158,8 +158,13 @@ typedef union StackValue { typedef StackValue *StkId; +/* +** When reallocating the stack, change all pointers to the stack into +** proper offsets. +*/ typedef union { StkId p; /* actual pointer */ + ptrdiff_t offset; /* used while the stack is being reallocated */ } StkIdRel; @@ -626,6 +631,7 @@ typedef struct UpVal { lu_byte tbc; /* true if it represents a to-be-closed variable */ union { TValue *p; /* points to stack or to its own value */ + ptrdiff_t offset; /* used while the stack is being reallocated */ } v; union { struct { /* (when open) */ -- cgit v1.2.3-55-g6feb