aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-04-06 09:23:48 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-04-06 09:23:48 -0300
commit67bf789462136e45692b4e31e41ef3abead1b2a2 (patch)
treeae44201ccbff34a79fa1d56fb4bb5eedc919816c
parent48d0674c2e85ef7bb447a8a45fbc6af80508f10e (diff)
downloadlua-67bf789462136e45692b4e31e41ef3abead1b2a2.tar.gz
lua-67bf789462136e45692b4e31e41ef3abead1b2a2.tar.bz2
lua-67bf789462136e45692b4e31e41ef3abead1b2a2.zip
avoid using API functions inside the core
-rw-r--r--lapi.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/lapi.c b/lapi.c
index 595a4512..608d48c2 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.247 2015/03/06 19:49:50 roberto Exp roberto $ 2** $Id: lapi.c,v 2.248 2015/03/28 19:14:47 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*/
@@ -434,9 +434,8 @@ LUA_API const void *lua_topointer (lua_State *L, int idx) {
434 case LUA_TCCL: return clCvalue(o); 434 case LUA_TCCL: return clCvalue(o);
435 case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o))); 435 case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o)));
436 case LUA_TTHREAD: return thvalue(o); 436 case LUA_TTHREAD: return thvalue(o);
437 case LUA_TUSERDATA: 437 case LUA_TUSERDATA: return getudatamem(uvalue(o));
438 case LUA_TLIGHTUSERDATA: 438 case LUA_TLIGHTUSERDATA: return pvalue(o);
439 return lua_touserdata(L, idx);
440 default: return NULL; 439 default: return NULL;
441 } 440 }
442} 441}
@@ -485,20 +484,19 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
485 484
486 485
487LUA_API const char *lua_pushstring (lua_State *L, const char *s) { 486LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
488 if (s == NULL) { 487 lua_lock(L);
489 lua_pushnil(L); 488 if (s == NULL)
490 return NULL; 489 setnilvalue(L->top);
491 }
492 else { 490 else {
493 TString *ts; 491 TString *ts;
494 lua_lock(L);
495 luaC_checkGC(L); 492 luaC_checkGC(L);
496 ts = luaS_new(L, s); 493 ts = luaS_new(L, s);
497 setsvalue2s(L, L->top, ts); 494 setsvalue2s(L, L->top, ts);
498 api_incr_top(L); 495 s = getstr(ts); /* internal copy's address */
499 lua_unlock(L);
500 return getstr(ts);
501 } 496 }
497 api_incr_top(L);
498 lua_unlock(L);
499 return s;
502} 500}
503 501
504 502