Roberto Ierusalimschy %!s(int64=22) %!d(string=hai) anos
pai
achega
67f9a2a98f
Modificáronse 3 ficheiros con 13 adicións e 9 borrados
  1. 4 4
      lapi.c
  2. 4 1
      llimits.h
  3. 5 4
      ltable.c

+ 4 - 4
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);

+ 4 - 1
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;
 

+ 5 - 4
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)++;