From 67f9a2a98f245f3468f1671bb1f51ffabb4581be Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 20 Feb 2003 17:12:39 -0300 Subject: details --- lapi.c | 8 ++++---- llimits.h | 5 ++++- ltable.c | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lapi.c b/lapi.c index 7114d1e5..74df3410 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.228 2003/02/11 10:46:24 roberto Exp roberto $ +** $Id: lapi.c,v 1.229 2003/02/18 16:13:15 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -755,7 +755,7 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { /* GC values are expressed in Kbytes: #bytes/2^10 */ #define GCscalel(x) ((x)>>10) #define GCscale(x) (cast(int, GCscalel(x))) -#define GCunscale(x) (cast(lu_mem, (x)<<10)) +#define GCunscale(x) (cast(lu_mem, x)<<10) LUA_API int lua_getgcthreshold (lua_State *L) { int threshold; @@ -775,8 +775,8 @@ LUA_API int lua_getgccount (lua_State *L) { LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { lua_lock(L); - if (cast(lu_mem, newthreshold) > GCscalel(ULONG_MAX)) - G(L)->GCthreshold = ULONG_MAX; + if (cast(lu_mem, newthreshold) > GCscalel(MAX_LUMEM)) + G(L)->GCthreshold = MAX_LUMEM; else G(L)->GCthreshold = GCunscale(newthreshold); luaC_checkGC(L); diff --git a/llimits.h b/llimits.h index c2fb9589..e5d0a7f0 100644 --- a/llimits.h +++ b/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.50 2002/11/22 18:01:46 roberto Exp roberto $ +** $Id: llimits.h,v 1.51 2002/11/25 17:47:13 roberto Exp roberto $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -49,6 +49,9 @@ typedef int ls_hash; /* it should be at least as large as size_t */ typedef unsigned long lu_mem; +#define MAX_LUMEM ULONG_MAX + + /* an integer big enough to count the number of strings in use */ typedef long ls_nstr; diff --git a/ltable.c b/ltable.c index a8abe5f6..28634cc5 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 1.126 2002/12/04 17:38:31 roberto Exp roberto $ +** $Id: ltable.c,v 1.127 2003/02/13 16:08:32 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -160,7 +160,7 @@ static void computesizes (int nums[], int ntotal, int *narray, int *nhash) { int a = nums[0]; /* number of elements smaller than 2^i */ int na = a; /* number of elements to go to array part */ int n = (na == 0) ? -1 : 0; /* (log of) optimal size for array part */ - for (i = 1; i <= MAXBITS && *narray >= twoto(i-1); i++) { + for (i = 1; a < *narray && *narray >= twoto(i-1); i++) { if (nums[i] > 0) { a += nums[i]; if (a >= twoto(i-1)) { /* more than half elements in use? */ @@ -200,8 +200,9 @@ static void numuse (const Table *t, int *narray, int *nhash) { /* count elements in hash part */ i = sizenode(t); while (i--) { - if (!ttisnil(val(&t->node[i]))) { - int k = arrayindex(key(&t->node[i])); + Node *n = &t->node[i]; + if (!ttisnil(val(n))) { + int k = arrayindex(key(n)); if (k >= 0) { /* is `key' an appropriate array index? */ nums[luaO_log2(k-1)+1]++; /* count as such */ (*narray)++; -- cgit v1.2.3-55-g6feb