more complete (and hopefuly more correct) handling of 'sizeof(char)'

This commit is contained in:
Roberto Ierusalimschy
2011-05-03 13:01:57 -03:00
parent bc1c718cc0
commit ad2531a0ee
6 changed files with 29 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lstring.c,v 2.17 2010/04/03 20:24:18 roberto Exp roberto $
** $Id: lstring.c,v 2.18 2010/05/10 18:23:45 roberto Exp roberto $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
@@ -84,8 +84,9 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
o != NULL;
o = gch(o)->next) {
TString *ts = rawgco2ts(o);
if (h == ts->tsv.hash && ts->tsv.len == l &&
(memcmp(str, getstr(ts), l) == 0)) {
if (h == ts->tsv.hash &&
ts->tsv.len == l &&
(memcmp(str, getstr(ts), l * sizeof(char)) == 0)) {
if (isdead(G(L), o)) /* string is dead (but was not collected yet)? */
changewhite(o); /* resurrect it */
return ts;