lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 38d3bc89093010fa9c460b61a1965d9077b5378f
parent 75efc6722bf3bf31adffed44407674f74ac6caed
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Sun, 25 Feb 2018 10:39:33 -0300

using 'offsetof' to compute the size of parts of a structure

Diffstat:
Mlfunc.h | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lfunc.h b/lfunc.h @@ -1,5 +1,5 @@ /* -** $Id: lfunc.h,v 2.18 2017/06/29 15:06:44 roberto Exp roberto $ +** $Id: lfunc.h,v 2.19 2018/01/28 15:13:26 roberto Exp roberto $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -11,11 +11,11 @@ #include "lobject.h" -#define sizeCclosure(n) (cast_int(sizeof(CClosure)) + \ - cast_int(sizeof(TValue)*((n)-1))) +#define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ + cast_int(sizeof(TValue)) * (n)) -#define sizeLclosure(n) (cast_int(sizeof(LClosure)) + \ - cast_int(sizeof(TValue *)*((n)-1))) +#define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ + cast_int(sizeof(TValue *)) * (n)) /* test whether thread is in 'twups' list */