diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-09 17:53:16 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-09 17:53:16 -0200 |
commit | 6875fdc8be9029b1bb29379c59d5409a0df42c10 (patch) | |
tree | af7d5845b1e209473ecf8ad0f53a188974628b20 /lstring.c | |
parent | dc17a9cc24a52a298dbfb7ffe8aaad393f7c1bf9 (diff) | |
download | lua-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.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -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 | ||
105 | TString *luaS_createudata (lua_State *L, void *udata, int tag) { | 105 | int 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 | ||