From 675530c4d8be0b240f81e7f8cf147f42a3205b49 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Sun, 13 Apr 2014 18:11:19 -0300 Subject: maximum size of array part of a table now is restricted not only by the size of an 'int', but also by the size of a 'lua_Integer' --- ltable.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ltable.c b/ltable.c index 74feb4bd..3d4f3c38 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.84 2014/01/27 13:34:32 roberto Exp roberto $ +** $Id: ltable.c,v 2.85 2014/04/01 14:39:55 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -21,6 +21,7 @@ #include #include #include +#include #define ltable_c #define LUA_CORE @@ -39,14 +40,13 @@ /* -** max size of array part is 2^MAXBITS +** Maximum size of array part (MAXASIZE) is 2^MAXBITS. (SIZEINT is the +** minimum between size of int and size of LUA_INTEGER; array indices +** are limited by both types.) */ -#if LUAI_BITSINT >= 32 -#define MAXBITS 30 -#else -#define MAXBITS (LUAI_BITSINT-2) -#endif - +#define SIZEINT \ + (sizeof(int) < sizeof(LUA_INTEGER) ? sizeof(int) : sizeof(LUA_INTEGER)) +#define MAXBITS cast_int(SIZEINT * CHAR_BIT - 2) #define MAXASIZE (1 << MAXBITS) -- cgit v1.2.3-55-g6feb