diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-06-19 11:27:00 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-06-19 11:27:00 -0300 |
| commit | 130c0e40e01e24a79f7e416d1cc4187cd4a2a5fc (patch) | |
| tree | 946ed95a3c70012ba57e0be4abdd4a5e7263fc44 /lstring.c | |
| parent | c72fb1cf8e0869aa4adc894c4e28f9d1be2e6574 (diff) | |
| download | lua-130c0e40e01e24a79f7e416d1cc4187cd4a2a5fc.tar.gz lua-130c0e40e01e24a79f7e416d1cc4187cd4a2a5fc.tar.bz2 lua-130c0e40e01e24a79f7e416d1cc4187cd4a2a5fc.zip | |
new constant 'MAX_SIZE', distinct from 'MAX_SIZET', for sizes visible
from Lua; these must fit in a lua_Integer
Diffstat (limited to 'lstring.c')
| -rw-r--r-- | lstring.c | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.c,v 2.25 2012/10/02 17:41:50 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.26 2013/01/08 13:50:10 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 | */ |
| @@ -157,7 +157,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { | |||
| 157 | if (l <= LUAI_MAXSHORTLEN) /* short string? */ | 157 | if (l <= LUAI_MAXSHORTLEN) /* short string? */ |
| 158 | return internshrstr(L, str, l); | 158 | return internshrstr(L, str, l); |
| 159 | else { | 159 | else { |
| 160 | if (l + 1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) | 160 | if (l + 1 > (MAX_SIZE - sizeof(TString))/sizeof(char)) |
| 161 | luaM_toobig(L); | 161 | luaM_toobig(L); |
| 162 | return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL); | 162 | return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL); |
| 163 | } | 163 | } |
| @@ -174,7 +174,7 @@ TString *luaS_new (lua_State *L, const char *str) { | |||
| 174 | 174 | ||
| 175 | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { | 175 | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { |
| 176 | Udata *u; | 176 | Udata *u; |
| 177 | if (s > MAX_SIZET - sizeof(Udata)) | 177 | if (s > MAX_SIZE - sizeof(Udata)) |
| 178 | luaM_toobig(L); | 178 | luaM_toobig(L); |
| 179 | u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u; | 179 | u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u; |
| 180 | u->uv.len = s; | 180 | u->uv.len = s; |
