lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 03d8a9bf0d8d9c149c0c2c0ae63732a8bfa512fd
parent d2e340f467a46017fa3526074c1756124e569880
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri,  9 Feb 2001 18:29:11 -0200

details

Diffstat:
Mllimits.h | 4++--
Mlstring.c | 7+++----
Mltests.c | 6++++--
3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/llimits.h b/llimits.h @@ -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 ** 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) */ #define SIZE_INSTRUCTION 32 -#define SIZE_B 9 +#define SIZE_B 8 #define SIZE_OP 6 #define SIZE_U (SIZE_INSTRUCTION-SIZE_OP) diff --git a/lstring.c b/lstring.c @@ -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) ** 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) { - union L_UTString *uts = (union L_UTString *)luaM_malloc(L, sizeudata(s)); - TString *ts = &uts->ts; + TString *ts = (TString *)luaM_malloc(L, sizeudata(s)); ts->marked = 0; ts->nexthash = NULL; ts->len = s; 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 */ newentry(L, &G(L)->udt, ts, lmod(IntPoint(ts->u.d.value), G(L)->udt.size)); return ts; diff --git a/ltests.c b/ltests.c @@ -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 ** See Copyright Notice in lua.h */ @@ -356,7 +356,9 @@ static int newuserdata (lua_State *L) { return 2; } 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; } }