Skip to content

Commit

Permalink
using 'offsetof' to compute the size of parts of a structure
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-ieru committed Feb 25, 2018
1 parent 75efc67 commit 38d3bc8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lfunc.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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 */
Expand Down

0 comments on commit 38d3bc8

Please sign in to comment.