aboutsummaryrefslogtreecommitdiff
path: root/lstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lstring.c b/lstring.c
index 507e945a..ebae208a 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.35 2000/05/08 19:32:53 roberto Exp roberto $ 2** $Id: lstring.c,v 1.36 2000/05/10 16:33:20 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*/
@@ -34,10 +34,10 @@ void luaS_freeall (lua_State *L) {
34} 34}
35 35
36 36
37static unsigned long hash_s (const char *s, long l) { 37static unsigned long hash_s (const char *s, size_t l) {
38 unsigned long h = l; /* seed */ 38 unsigned long h = l; /* seed */
39 long step = (l>>6)+1; /* if string is too long, don't hash all its chars */ 39 size_t step = (l>>6)|1; /* if string is too long, don't hash all its chars */
40 for (; l>0; l-=step) 40 for (; l>=step; l-=step)
41 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++)); 41 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++));
42 return h; 42 return h;
43} 43}
@@ -71,13 +71,13 @@ static void newentry (lua_State *L, stringtable *tb, TString *ts, int h) {
71 ts->nexthash = tb->hash[h]; /* chain new entry */ 71 ts->nexthash = tb->hash[h]; /* chain new entry */
72 tb->hash[h] = ts; 72 tb->hash[h] = ts;
73 tb->nuse++; 73 tb->nuse++;
74 if (tb->nuse > tb->size && tb->size < MAX_INT/2) /* too crowded? */ 74 if (tb->nuse > (lint32)tb->size && tb->size < MAX_INT/2) /* too crowded? */
75 luaS_resize(L, tb, tb->size*2); 75 luaS_resize(L, tb, tb->size*2);
76} 76}
77 77
78 78
79 79
80TString *luaS_newlstr (lua_State *L, const char *str, long l) { 80TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
81 unsigned long h = hash_s(str, l); 81 unsigned long h = hash_s(str, l);
82 int h1 = h&(L->strt.size-1); 82 int h1 = h&(L->strt.size-1);
83 TString *ts; 83 TString *ts;
@@ -86,7 +86,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, long l) {
86 return ts; 86 return ts;
87 } 87 }
88 /* not found */ 88 /* not found */
89 ts = (TString *)luaM_malloc(L, sizeof(TString)+l*sizeof(char)); 89 ts = (TString *)luaM_malloc(L, sizeof(TString)+(lint32)l*sizeof(char));
90 ts->marked = 0; 90 ts->marked = 0;
91 ts->nexthash = NULL; 91 ts->nexthash = NULL;
92 ts->u.s.len = l; 92 ts->u.s.len = l;