diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-20 17:12:39 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-20 17:12:39 -0300 |
commit | 67f9a2a98f245f3468f1671bb1f51ffabb4581be (patch) | |
tree | fa3453c1c6f8fe00f6c327e277a02ea72ebb8138 | |
parent | c4f9c887fc8dc514b9de30ce395517caad973246 (diff) | |
download | lua-67f9a2a98f245f3468f1671bb1f51ffabb4581be.tar.gz lua-67f9a2a98f245f3468f1671bb1f51ffabb4581be.tar.bz2 lua-67f9a2a98f245f3468f1671bb1f51ffabb4581be.zip |
details
-rw-r--r-- | lapi.c | 8 | ||||
-rw-r--r-- | llimits.h | 5 | ||||
-rw-r--r-- | ltable.c | 9 |
3 files changed, 13 insertions, 9 deletions
@@ -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 | ||
760 | LUA_API int lua_getgcthreshold (lua_State *L) { | 760 | LUA_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 | ||
776 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { | 776 | LUA_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); |
@@ -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 */ |
50 | typedef unsigned long lu_mem; | 50 | typedef 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 */ |
53 | typedef long ls_nstr; | 56 | typedef long ls_nstr; |
54 | 57 | ||
@@ -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)++; |