confirmed that this is the same

And it seems simpler to me.
This commit is contained in:
Kartik K. Agaram 2021-11-04 08:10:25 -07:00
parent 712dc16b23
commit f53ca6f804
1 changed files with 2 additions and 2 deletions

View File

@ -378,13 +378,13 @@ static int pmain (lua_State *L) {
typedef struct NumArray {
int size;
double values[1]; /* variable part */
double values[0]; /* variable part */
} NumArray;
static int newarray (lua_State *L) {
int n = luaL_checkint(L, 1);
size_t nbytes = sizeof(NumArray) + (n - 1)*sizeof(double);
size_t nbytes = sizeof(NumArray) + n*sizeof(double);
NumArray *a = (NumArray *)lua_newuserdata(L, nbytes);
a->size = n;
return 1; /* new userdatum is already on the stack */