diff options
| -rw-r--r-- | pez.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -86,9 +86,11 @@ typedef struct Proto { typedef struct Upval Upval; struct Upval { OBJHEADER; - Upval *nextup; Val *ptr; - Val slot; + union { + Upval *nextup; + Val slot; + }; }; typedef struct Fn { @@ -471,11 +473,12 @@ delproto(PezContext *cx, Proto *pr) static void closeups(PezContext *cx, Val *vals) { - for (Upval *up = cx->openup; up; up = up->nextup) { + for (Upval *up = cx->openup, *next; up; up = next) { + next = up->nextup; if (up->ptr >= vals) { + cx->openup = next; up->slot = *up->ptr; up->ptr = &up->slot; - cx->openup = up->nextup; } } } |