aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-15 17:36:57 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-15 17:36:57 -0300
commit8e586c13fcf3066886a7edd69011304eaad57a2b (patch)
tree417c2102ba8c4d693c49a2df839612d371eded50 /lapi.c
parenteadf2aaaffa7a35e7f67b150ce0d57f2c17b9231 (diff)
downloadlua-8e586c13fcf3066886a7edd69011304eaad57a2b.tar.gz
lua-8e586c13fcf3066886a7edd69011304eaad57a2b.tar.bz2
lua-8e586c13fcf3066886a7edd69011304eaad57a2b.zip
cleaner way to ensure alignment for strings and userdata
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lapi.c b/lapi.c
index effcc2aa..31f11702 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.144 2001/06/08 19:00:57 roberto Exp roberto $ 2** $Id: lapi.c,v 1.145 2001/06/15 19:16:41 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*/
@@ -244,11 +244,11 @@ LUA_API size_t lua_strlen (lua_State *L, int index) {
244 if (o == NULL) 244 if (o == NULL)
245 return 0; 245 return 0;
246 else if (ttype(o) == LUA_TSTRING) 246 else if (ttype(o) == LUA_TSTRING)
247 return tsvalue(o)->len; 247 return tsvalue(o)->tsv.len;
248 else { 248 else {
249 size_t l; 249 size_t l;
250 lua_lock(L); /* `luaV_tostring' may create a new string */ 250 lua_lock(L); /* `luaV_tostring' may create a new string */
251 l = (luaV_tostring(L, o) == 0) ? tsvalue(o)->len : 0; 251 l = (luaV_tostring(L, o) == 0) ? tsvalue(o)->tsv.len : 0;
252 lua_unlock(L); 252 lua_unlock(L);
253 return l; 253 return l;
254 } 254 }
@@ -263,7 +263,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
263 263
264LUA_API void *lua_touserdata (lua_State *L, int index) { 264LUA_API void *lua_touserdata (lua_State *L, int index) {
265 StkId o = luaA_indexAcceptable(L, index); 265 StkId o = luaA_indexAcceptable(L, index);
266 return (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL : uvalue(o)->value; 266 return (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL : uvalue(o)->uv.value;
267} 267}
268 268
269 269
@@ -633,7 +633,7 @@ LUA_API void lua_settag (lua_State *L, int tag) {
633 hvalue(L->top-1)->htag = tag; 633 hvalue(L->top-1)->htag = tag;
634 break; 634 break;
635 case LUA_TUSERDATA: 635 case LUA_TUSERDATA:
636 uvalue(L->top-1)->tag = tag; 636 uvalue(L->top-1)->uv.tag = tag;
637 break; 637 break;
638 default: 638 default:
639 luaO_verror(L, l_s("cannot change the tag of a %.20s"), 639 luaO_verror(L, l_s("cannot change the tag of a %.20s"),
@@ -744,7 +744,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
744 void *p; 744 void *p;
745 lua_lock(L); 745 lua_lock(L);
746 u = pushnewudata(L, size); 746 u = pushnewudata(L, size);
747 p = u->value; 747 p = u->uv.value;
748 lua_unlock(L); 748 lua_unlock(L);
749 return p; 749 return p;
750} 750}
@@ -754,7 +754,7 @@ LUA_API void lua_newuserdatabox (lua_State *L, void *p) {
754 Udata *u; 754 Udata *u;
755 lua_lock(L); 755 lua_lock(L);
756 u = pushnewudata(L, 0); 756 u = pushnewudata(L, 0);
757 u->value = p; 757 u->uv.value = p;
758 lua_unlock(L); 758 lua_unlock(L);
759} 759}
760 760