mirror of
https://github.com/lua/lua
synced 2025-01-07 10:02:01 +03:00
ULONG_MAX>>10 may not fit into an int
This commit is contained in:
parent
dbc5451bea
commit
709b27b456
7
lapi.c
7
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);
|
||||
|
Loading…
Reference in New Issue
Block a user