diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-21 13:51:25 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-21 13:51:25 -0300 |
| commit | d6978d03e195fe4af788fe5078ec4f1df601405e (patch) | |
| tree | a9bc771d95f50b75767d1a108d7d7fcd474d7fce | |
| parent | 68b08848d4ce0fcdcab8d7d1489cf77a6efd7ae8 (diff) | |
| download | lua-d6978d03e195fe4af788fe5078ec4f1df601405e.tar.gz lua-d6978d03e195fe4af788fe5078ec4f1df601405e.tar.bz2 lua-d6978d03e195fe4af788fe5078ec4f1df601405e.zip | |
small bug in testing (pushuserdata needs some memory to work...)
Diffstat (limited to '')
| -rw-r--r-- | ltests.c | 13 |
1 files changed, 6 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.68 2001/02/13 16:52:01 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.69 2001/02/20 18:18:00 roberto Exp roberto $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -99,7 +99,7 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) { | |||
| 99 | freeblock(block); | 99 | freeblock(block); |
| 100 | return NULL; | 100 | return NULL; |
| 101 | } | 101 | } |
| 102 | else if (memdebug_total+size > memdebug_memlimit) | 102 | else if (memdebug_total+size-oldsize > memdebug_memlimit) |
| 103 | return NULL; /* to test memory allocation errors */ | 103 | return NULL; /* to test memory allocation errors */ |
| 104 | else { | 104 | else { |
| 105 | char *newblock; | 105 | char *newblock; |
| @@ -409,7 +409,7 @@ static int newstate (lua_State *L) { | |||
| 409 | lua_State *L1 = lua_open(NULL, luaL_check_int(L, 1)); | 409 | lua_State *L1 = lua_open(NULL, luaL_check_int(L, 1)); |
| 410 | if (L1) { | 410 | if (L1) { |
| 411 | *((int **)L1) = &islocked; /* initialize the lock */ | 411 | *((int **)L1) = &islocked; /* initialize the lock */ |
| 412 | lua_pushuserdata(L, L1); | 412 | lua_pushnumber(L, (unsigned long)L1); |
| 413 | } | 413 | } |
| 414 | else | 414 | else |
| 415 | lua_pushnil(L); | 415 | lua_pushnil(L); |
| @@ -430,8 +430,8 @@ static int loadlib (lua_State *L) { | |||
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | static int closestate (lua_State *L) { | 432 | static int closestate (lua_State *L) { |
| 433 | luaL_checktype(L, 1, LUA_TUSERDATA); | 433 | lua_State *L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); |
| 434 | lua_close((lua_State *)lua_touserdata(L, 1)); | 434 | lua_close(L1); |
| 435 | LUA_UNLOCK(L); /* close cannot unlock that */ | 435 | LUA_UNLOCK(L); /* close cannot unlock that */ |
| 436 | return 0; | 436 | return 0; |
| 437 | } | 437 | } |
| @@ -440,8 +440,7 @@ static int doremote (lua_State *L) { | |||
| 440 | lua_State *L1; | 440 | lua_State *L1; |
| 441 | const char *code = luaL_check_string(L, 2); | 441 | const char *code = luaL_check_string(L, 2); |
| 442 | int status; | 442 | int status; |
| 443 | luaL_checktype(L, 1, LUA_TUSERDATA); | 443 | L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); |
| 444 | L1 = (lua_State *)lua_touserdata(L, 1); | ||
| 445 | status = lua_dostring(L1, code); | 444 | status = lua_dostring(L1, code); |
| 446 | if (status != 0) { | 445 | if (status != 0) { |
| 447 | lua_pushnil(L); | 446 | lua_pushnil(L); |
