aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-02-20 17:12:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-02-20 17:12:39 -0300
commit67f9a2a98f245f3468f1671bb1f51ffabb4581be (patch)
treefa3453c1c6f8fe00f6c327e277a02ea72ebb8138
parentc4f9c887fc8dc514b9de30ce395517caad973246 (diff)
downloadlua-67f9a2a98f245f3468f1671bb1f51ffabb4581be.tar.gz
lua-67f9a2a98f245f3468f1671bb1f51ffabb4581be.tar.bz2
lua-67f9a2a98f245f3468f1671bb1f51ffabb4581be.zip
details
-rw-r--r--lapi.c8
-rw-r--r--llimits.h5
-rw-r--r--ltable.c9
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 @@
1/* 1/*
2** $Id: lapi.c,v 1.228 2003/02/11 10:46:24 roberto Exp roberto $ 2** $Id: lapi.c,v 1.229 2003/02/18 16:13:15 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -755,7 +755,7 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
755/* GC values are expressed in Kbytes: #bytes/2^10 */ 755/* GC values are expressed in Kbytes: #bytes/2^10 */
756#define GCscalel(x) ((x)>>10) 756#define GCscalel(x) ((x)>>10)
757#define GCscale(x) (cast(int, GCscalel(x))) 757#define GCscale(x) (cast(int, GCscalel(x)))
758#define GCunscale(x) (cast(lu_mem, (x)<<10)) 758#define GCunscale(x) (cast(lu_mem, x)<<10)
759 759
760LUA_API int lua_getgcthreshold (lua_State *L) { 760LUA_API int lua_getgcthreshold (lua_State *L) {
761 int threshold; 761 int threshold;
@@ -775,8 +775,8 @@ LUA_API int lua_getgccount (lua_State *L) {
775 775
776LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { 776LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
777 lua_lock(L); 777 lua_lock(L);
778 if (cast(lu_mem, newthreshold) > GCscalel(ULONG_MAX)) 778 if (cast(lu_mem, newthreshold) > GCscalel(MAX_LUMEM))
779 G(L)->GCthreshold = ULONG_MAX; 779 G(L)->GCthreshold = MAX_LUMEM;
780 else 780 else
781 G(L)->GCthreshold = GCunscale(newthreshold); 781 G(L)->GCthreshold = GCunscale(newthreshold);
782 luaC_checkGC(L); 782 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 @@
1/* 1/*
2** $Id: llimits.h,v 1.50 2002/11/22 18:01:46 roberto Exp roberto $ 2** $Id: llimits.h,v 1.51 2002/11/25 17:47:13 roberto Exp roberto $
3** Limits, basic types, and some other `installation-dependent' definitions 3** Limits, basic types, and some other `installation-dependent' definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -49,6 +49,9 @@ typedef int ls_hash;
49/* it should be at least as large as size_t */ 49/* it should be at least as large as size_t */
50typedef unsigned long lu_mem; 50typedef unsigned long lu_mem;
51 51
52#define MAX_LUMEM ULONG_MAX
53
54
52/* an integer big enough to count the number of strings in use */ 55/* an integer big enough to count the number of strings in use */
53typedef long ls_nstr; 56typedef long ls_nstr;
54 57
diff --git a/ltable.c b/ltable.c
index a8abe5f6..28634cc5 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.126 2002/12/04 17:38:31 roberto Exp roberto $ 2** $Id: ltable.c,v 1.127 2003/02/13 16:08:32 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -160,7 +160,7 @@ static void computesizes (int nums[], int ntotal, int *narray, int *nhash) {
160 int a = nums[0]; /* number of elements smaller than 2^i */ 160 int a = nums[0]; /* number of elements smaller than 2^i */
161 int na = a; /* number of elements to go to array part */ 161 int na = a; /* number of elements to go to array part */
162 int n = (na == 0) ? -1 : 0; /* (log of) optimal size for array part */ 162 int n = (na == 0) ? -1 : 0; /* (log of) optimal size for array part */
163 for (i = 1; i <= MAXBITS && *narray >= twoto(i-1); i++) { 163 for (i = 1; a < *narray && *narray >= twoto(i-1); i++) {
164 if (nums[i] > 0) { 164 if (nums[i] > 0) {
165 a += nums[i]; 165 a += nums[i];
166 if (a >= twoto(i-1)) { /* more than half elements in use? */ 166 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) {
200 /* count elements in hash part */ 200 /* count elements in hash part */
201 i = sizenode(t); 201 i = sizenode(t);
202 while (i--) { 202 while (i--) {
203 if (!ttisnil(val(&t->node[i]))) { 203 Node *n = &t->node[i];
204 int k = arrayindex(key(&t->node[i])); 204 if (!ttisnil(val(n))) {
205 int k = arrayindex(key(n));
205 if (k >= 0) { /* is `key' an appropriate array index? */ 206 if (k >= 0) { /* is `key' an appropriate array index? */
206 nums[luaO_log2(k-1)+1]++; /* count as such */ 207 nums[luaO_log2(k-1)+1]++; /* count as such */
207 (*narray)++; 208 (*narray)++;