This commit is contained in:
Roberto Ierusalimschy 2001-02-09 18:29:33 -02:00
parent d2e340f467
commit 03d8a9bf0d
3 changed files with 9 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: llimits.h,v 1.20 2000/11/24 17:39:56 roberto Exp roberto $ ** $Id: llimits.h,v 1.21 2000/12/04 18:33:40 roberto Exp roberto $
** Limits, basic types, and some other "installation-dependent" definitions ** Limits, basic types, and some other "installation-dependent" definitions
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -90,7 +90,7 @@ typedef luint32 Instruction;
** (accordingly, size_u will be 10, and size_a will be 5) ** (accordingly, size_u will be 10, and size_a will be 5)
*/ */
#define SIZE_INSTRUCTION 32 #define SIZE_INSTRUCTION 32
#define SIZE_B 9 #define SIZE_B 8
#define SIZE_OP 6 #define SIZE_OP 6
#define SIZE_U (SIZE_INSTRUCTION-SIZE_OP) #define SIZE_U (SIZE_INSTRUCTION-SIZE_OP)

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lstring.c,v 1.56 2001/02/09 19:53:16 roberto Exp roberto $ ** $Id: lstring.c,v 1.57 2001/02/09 20:22:29 roberto Exp roberto $
** String table (keeps all strings handled by Lua) ** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -89,13 +89,12 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
TString *luaS_newudata (lua_State *L, size_t s, void *udata) { TString *luaS_newudata (lua_State *L, size_t s, void *udata) {
union L_UTString *uts = (union L_UTString *)luaM_malloc(L, sizeudata(s)); TString *ts = (TString *)luaM_malloc(L, sizeudata(s));
TString *ts = &uts->ts;
ts->marked = 0; ts->marked = 0;
ts->nexthash = NULL; ts->nexthash = NULL;
ts->len = s; ts->len = s;
ts->u.d.tag = 0; ts->u.d.tag = 0;
ts->u.d.value = (s > 0) ? uts+1 : udata; ts->u.d.value = (s > 0) ? getstr(ts) : udata;
/* insert it on table */ /* insert it on table */
newentry(L, &G(L)->udt, ts, lmod(IntPoint(ts->u.d.value), G(L)->udt.size)); newentry(L, &G(L)->udt, ts, lmod(IntPoint(ts->u.d.value), G(L)->udt.size));
return ts; return ts;

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltests.c,v 1.65 2001/02/09 19:53:16 roberto Exp roberto $ ** $Id: ltests.c,v 1.66 2001/02/09 20:22:29 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation ** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -356,7 +356,9 @@ static int newuserdata (lua_State *L) {
return 2; return 2;
} }
else { else {
lua_newuserdata(L, luaL_check_int(L, 1)); size_t size = luaL_check_int(L, 1);
char *p = (char *)lua_newuserdata(L, size);
while (size--) *p++ = '\0';
return 1; return 1;
} }
} }