From 709b27b4564f3e4df22b973649f202fd5bb7a04a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 25 Nov 2002 09:16:48 -0200 Subject: [PATCH] ULONG_MAX>>10 may not fit into an int --- lapi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lapi.c b/lapi.c index 46f2e1a4..a769d9d8 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.221 2002/11/21 14:16:52 roberto Exp roberto $ +** $Id: lapi.c,v 1.222 2002/11/21 15:16:04 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -697,7 +697,8 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { */ /* GC values are expressed in Kbytes: #bytes/2^10 */ -#define GCscale(x) (cast(int, (x)>>10)) +#define GCscalel(x) ((x)>>10) +#define GCscale(x) (cast(int, GCscalel(x))) #define GCunscale(x) (cast(lu_mem, (x)<<10)) LUA_API int lua_getgcthreshold (lua_State *L) { @@ -718,7 +719,7 @@ LUA_API int lua_getgccount (lua_State *L) { LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { lua_lock(L); - if (newthreshold > GCscale(ULONG_MAX)) + if (cast(lu_mem, newthreshold) > GCscalel(ULONG_MAX)) G(L)->GCthreshold = ULONG_MAX; else G(L)->GCthreshold = GCunscale(newthreshold);