details
This commit is contained in:
8
lapi.c
8
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
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** 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 */
|
/* GC values are expressed in Kbytes: #bytes/2^10 */
|
||||||
#define GCscalel(x) ((x)>>10)
|
#define GCscalel(x) ((x)>>10)
|
||||||
#define GCscale(x) (cast(int, GCscalel(x)))
|
#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) {
|
LUA_API int lua_getgcthreshold (lua_State *L) {
|
||||||
int threshold;
|
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_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
if (cast(lu_mem, newthreshold) > GCscalel(ULONG_MAX))
|
if (cast(lu_mem, newthreshold) > GCscalel(MAX_LUMEM))
|
||||||
G(L)->GCthreshold = ULONG_MAX;
|
G(L)->GCthreshold = MAX_LUMEM;
|
||||||
else
|
else
|
||||||
G(L)->GCthreshold = GCunscale(newthreshold);
|
G(L)->GCthreshold = GCunscale(newthreshold);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
|
|||||||
@@ -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
|
** Limits, basic types, and some other `installation-dependent' definitions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -49,6 +49,9 @@ typedef int ls_hash;
|
|||||||
/* it should be at least as large as size_t */
|
/* it should be at least as large as size_t */
|
||||||
typedef unsigned long lu_mem;
|
typedef unsigned long lu_mem;
|
||||||
|
|
||||||
|
#define MAX_LUMEM ULONG_MAX
|
||||||
|
|
||||||
|
|
||||||
/* an integer big enough to count the number of strings in use */
|
/* an integer big enough to count the number of strings in use */
|
||||||
typedef long ls_nstr;
|
typedef long ls_nstr;
|
||||||
|
|
||||||
|
|||||||
9
ltable.c
9
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)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** 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 a = nums[0]; /* number of elements smaller than 2^i */
|
||||||
int na = a; /* number of elements to go to array part */
|
int na = a; /* number of elements to go to array part */
|
||||||
int n = (na == 0) ? -1 : 0; /* (log of) optimal size for 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) {
|
if (nums[i] > 0) {
|
||||||
a += nums[i];
|
a += nums[i];
|
||||||
if (a >= twoto(i-1)) { /* more than half elements in use? */
|
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 */
|
/* count elements in hash part */
|
||||||
i = sizenode(t);
|
i = sizenode(t);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
if (!ttisnil(val(&t->node[i]))) {
|
Node *n = &t->node[i];
|
||||||
int k = arrayindex(key(&t->node[i]));
|
if (!ttisnil(val(n))) {
|
||||||
|
int k = arrayindex(key(n));
|
||||||
if (k >= 0) { /* is `key' an appropriate array index? */
|
if (k >= 0) { /* is `key' an appropriate array index? */
|
||||||
nums[luaO_log2(k-1)+1]++; /* count as such */
|
nums[luaO_log2(k-1)+1]++; /* count as such */
|
||||||
(*narray)++;
|
(*narray)++;
|
||||||
|
|||||||
Reference in New Issue
Block a user