diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 10:40:00 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 10:40:00 -0300 |
| commit | 38d3bc89093010fa9c460b61a1965d9077b5378f (patch) | |
| tree | 183158bcdac55fc9a8be5b8011391ef0df3e1d70 | |
| parent | 75efc6722bf3bf31adffed44407674f74ac6caed (diff) | |
| download | lua-38d3bc89093010fa9c460b61a1965d9077b5378f.tar.gz lua-38d3bc89093010fa9c460b61a1965d9077b5378f.tar.bz2 lua-38d3bc89093010fa9c460b61a1965d9077b5378f.zip | |
using 'offsetof' to compute the size of parts of a structure
| -rw-r--r-- | lfunc.h | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.h,v 2.18 2017/06/29 15:06:44 roberto Exp roberto $ | 2 | ** $Id: lfunc.h,v 2.19 2018/01/28 15:13:26 roberto Exp roberto $ |
| 3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -11,11 +11,11 @@ | |||
| 11 | #include "lobject.h" | 11 | #include "lobject.h" |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | #define sizeCclosure(n) (cast_int(sizeof(CClosure)) + \ | 14 | #define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ |
| 15 | cast_int(sizeof(TValue)*((n)-1))) | 15 | cast_int(sizeof(TValue)) * (n)) |
| 16 | 16 | ||
| 17 | #define sizeLclosure(n) (cast_int(sizeof(LClosure)) + \ | 17 | #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ |
| 18 | cast_int(sizeof(TValue *)*((n)-1))) | 18 | cast_int(sizeof(TValue *)) * (n)) |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | /* test whether thread is in 'twups' list */ | 21 | /* test whether thread is in 'twups' list */ |
