aboutsummaryrefslogtreecommitdiff
path: root/lstring.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-09 18:22:29 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-09 18:22:29 -0200
commitd2e340f467a46017fa3526074c1756124e569880 (patch)
treee5b08773a0f0734193b0c1c435fab8ee243f08dc /lstring.c
parent6875fdc8be9029b1bb29379c59d5409a0df42c10 (diff)
downloadlua-d2e340f467a46017fa3526074c1756124e569880.tar.gz
lua-d2e340f467a46017fa3526074c1756124e569880.tar.bz2
lua-d2e340f467a46017fa3526074c1756124e569880.zip
string pointers are always fully aligned
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lstring.c b/lstring.c
index 48ffb3d7..f99e4c37 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.55 2001/02/01 17:40:48 roberto Exp roberto $ 2** $Id: lstring.c,v 1.56 2001/02/09 19:53:16 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*/
@@ -71,7 +71,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
71 for (l1=l; l1>=step; l1-=step) /* compute hash */ 71 for (l1=l; l1>=step; l1-=step) /* compute hash */
72 h = h ^ ((h<<5)+(h>>2)+(unsigned char)str[l1-1]); 72 h = h ^ ((h<<5)+(h>>2)+(unsigned char)str[l1-1]);
73 for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; ts; ts = ts->nexthash) { 73 for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; ts; ts = ts->nexthash) {
74 if (ts->len == l && (memcmp(str, ts->str, l) == 0)) 74 if (ts->len == l && (memcmp(str, getstr(ts), l) == 0))
75 return ts; 75 return ts;
76 } 76 }
77 /* not found */ 77 /* not found */
@@ -81,8 +81,8 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
81 ts->len = l; 81 ts->len = l;
82 ts->u.s.hash = h; 82 ts->u.s.hash = h;
83 ts->u.s.constindex = 0; 83 ts->u.s.constindex = 0;
84 memcpy(ts->str, str, l); 84 memcpy(getstr(ts), str, l);
85 ts->str[l] = 0; /* ending 0 */ 85 getstr(ts)[l] = 0; /* ending 0 */
86 newentry(L, &G(L)->strt, ts, lmod(h, G(L)->strt.size)); /* insert it */ 86 newentry(L, &G(L)->strt, ts, lmod(h, G(L)->strt.size)); /* insert it */
87 return ts; 87 return ts;
88} 88}