aboutsummaryrefslogtreecommitdiff
path: root/lstring.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-09 17:53:16 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-09 17:53:16 -0200
commit6875fdc8be9029b1bb29379c59d5409a0df42c10 (patch)
treeaf7d5845b1e209473ecf8ad0f53a188974628b20 /lstring.c
parentdc17a9cc24a52a298dbfb7ffe8aaad393f7c1bf9 (diff)
downloadlua-6875fdc8be9029b1bb29379c59d5409a0df42c10.tar.gz
lua-6875fdc8be9029b1bb29379c59d5409a0df42c10.tar.bz2
lua-6875fdc8be9029b1bb29379c59d5409a0df42c10.zip
new semantics for pushuserdata (no more different userdatas with same value)
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lstring.c b/lstring.c
index fe87f5c2..48ffb3d7 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.54 2001/02/01 13:56:49 roberto Exp roberto $ 2** $Id: lstring.c,v 1.55 2001/02/01 17:40:48 roberto Exp roberto $
3** String table (keeps all strings handled by Lua) 3** String table (keeps all strings handled by Lua)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -102,17 +102,17 @@ TString *luaS_newudata (lua_State *L, size_t s, void *udata) {
102} 102}
103 103
104 104
105TString *luaS_createudata (lua_State *L, void *udata, int tag) { 105int luaS_createudata (lua_State *L, void *udata, TObject *o) {
106 int h1 = lmod(IntPoint(udata), G(L)->udt.size); 106 int h1 = lmod(IntPoint(udata), G(L)->udt.size);
107 TString *ts; 107 TString *ts;
108 for (ts = G(L)->udt.hash[h1]; ts; ts = ts->nexthash) { 108 for (ts = G(L)->udt.hash[h1]; ts; ts = ts->nexthash) {
109 if (udata == ts->u.d.value && (tag == ts->u.d.tag || tag == LUA_ANYTAG)) 109 if (udata == ts->u.d.value) {
110 return ts; 110 setuvalue(o, ts);
111 return 0;
112 }
111 } 113 }
112 /* not found */ 114 /* not found */
113 ts = luaS_newudata(L, 0, udata); 115 setuvalue(o, luaS_newudata(L, 0, udata));
114 if (tag != LUA_ANYTAG) 116 return 1;
115 ts->u.d.tag = tag;
116 return ts;
117} 117}
118 118