From 565e6d74e1440b1500d0ba0d3757307de0a38b9e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 19 Sep 2002 10:03:53 -0300 Subject: state's buffer is used only for chars --- llex.c | 4 ++-- lobject.c | 6 +++--- lobject.h | 5 ++--- lstate.h | 4 ++-- lundump.c | 4 ++-- lvm.c | 4 ++-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/llex.c b/llex.c index f0cf7146..83ac742d 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 1.110 2002/09/03 11:57:38 roberto Exp roberto $ +** $Id: llex.c,v 1.111 2002/09/05 19:45:42 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -141,7 +141,7 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) { #define EXTRABUFF 128 #define checkbuffer(L, len) \ if (((len)+10)*sizeof(char) > G(L)->Mbuffsize) \ - luaO_openspace(L, (len)+EXTRABUFF, char) + luaO_openspace(L, (len)+EXTRABUFF) #define save(L, c, l) (cast(char *, G(L)->Mbuffer)[l++] = cast(char, c)) #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) diff --git a/lobject.c b/lobject.c index 5845e695..dd8bfe08 100644 --- a/lobject.c +++ b/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 1.86 2002/08/07 14:35:55 roberto Exp roberto $ +** $Id: lobject.c,v 1.87 2002/09/02 19:54:49 roberto Exp roberto $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -72,9 +72,9 @@ int luaO_rawequalObj (const TObject *t1, const TObject *t2) { } -void *luaO_openspaceaux (lua_State *L, size_t n) { +char *luaO_openspace (lua_State *L, size_t n) { if (n > G(L)->Mbuffsize) { - G(L)->Mbuffer = luaM_realloc(L, G(L)->Mbuffer, G(L)->Mbuffsize, n); + luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, n, char); G(L)->Mbuffsize = n; } return G(L)->Mbuffer; diff --git a/lobject.h b/lobject.h index f80acfee..d9a5c242 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.144 2002/08/30 19:09:21 roberto Exp roberto $ +** $Id: lobject.h,v 1.145 2002/09/02 19:54:49 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -316,8 +316,7 @@ extern const TObject luaO_nilobject; int luaO_log2 (unsigned int x); -#define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) -void *luaO_openspaceaux (lua_State *L, size_t n); +char *luaO_openspace (lua_State *L, size_t n); int luaO_rawequalObj (const TObject *t1, const TObject *t2); int luaO_str2d (const char *s, lua_Number *result); diff --git a/lstate.h b/lstate.h index 5f592a9e..618685c1 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 1.94 2002/08/12 17:23:12 roberto Exp roberto $ +** $Id: lstate.h,v 1.95 2002/08/30 19:09:21 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -124,7 +124,7 @@ typedef struct global_State { GCObject *rootgc; /* list of (almost) all collectable objects */ GCObject *rootudata; /* (separated) list of all userdata */ GCObject *tmudata; /* list of userdata to be GC */ - void *Mbuffer; /* global buffer */ + char *Mbuffer; /* global buffer */ size_t Mbuffsize; /* size of Mbuffer */ lu_mem GCthreshold; lu_mem nblocks; /* number of `bytes' currently allocated */ diff --git a/lundump.c b/lundump.c index 425c31ac..6f2fa287 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 1.43 2002/08/07 00:36:03 lhf Exp $ +** $Id: lundump.c,v 1.52 2002/08/12 13:37:19 roberto Exp roberto $ ** load pre-compiled Lua chunks ** See Copyright Notice in lua.h */ @@ -99,7 +99,7 @@ static TString* LoadString (LoadState* S) return NULL; else { - char* s=luaO_openspace(S->L,size,char); + char* s=luaO_openspace(S->L,size); ezread(S,s,size); return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ } diff --git a/lvm.c b/lvm.c index 4487802e..7f9c08f3 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 1.253 2002/08/20 20:03:05 roberto Exp roberto $ +** $Id: lvm.c,v 1.254 2002/08/21 18:56:19 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -303,7 +303,7 @@ void luaV_concat (lua_State *L, int total, int last) { n++; } if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow"); - buffer = luaO_openspace(L, tl, char); + buffer = luaO_openspace(L, tl); tl = 0; for (i=n; i>0; i--) { /* concat all strings */ size_t l = tsvalue(top-i)->tsv.len; -- cgit v1.2.3-55-g6feb