aboutsummaryrefslogtreecommitdiff
path: root/lbuffer.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-05-24 10:54:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-05-24 10:54:49 -0300
commitef62b340e0a6b7b18931000dcbb19c4703bfe0e8 (patch)
treed9d995116a8a686b798d1b625b06ead26f28ba58 /lbuffer.c
parent5c2dd7a9e0a5b871a71ba66c4683cd88fe4f5aa4 (diff)
downloadlua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.tar.gz
lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.tar.bz2
lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.zip
code cleaner for 16 bits.
Diffstat (limited to 'lbuffer.c')
-rw-r--r--lbuffer.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lbuffer.c b/lbuffer.c
index f584936d..043ed5a3 100644
--- a/lbuffer.c
+++ b/lbuffer.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuffer.c,v 1.11 1999/11/22 13:12:07 roberto Exp roberto $ 2** $Id: lbuffer.c,v 1.12 2000/03/03 14:58:26 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -25,16 +25,17 @@
25#define EXTRABUFF 32 25#define EXTRABUFF 32
26 26
27 27
28#define openspace(L, size) if (L->Mbuffnext+(size) > L->Mbuffsize) \ 28#define openspace(L, size) if ((size_t)(size) > L->Mbuffsize-L->Mbuffnext) \
29 Openspace(L, size) 29 Openspace(L, size)
30 30
31static void Openspace (lua_State *L, int size) { 31static void Openspace (lua_State *L, size_t size) {
32 L->Mbuffsize = (L->Mbuffnext+size+EXTRABUFF)*2; 32 lint32 newsize = ((lint32)L->Mbuffnext+size+EXTRABUFF)*2;
33 luaM_reallocvector(L, L->Mbuffer, L->Mbuffsize, char); 33 luaM_reallocvector(L, L->Mbuffer, newsize, char);
34 L->Mbuffsize = newsize;
34} 35}
35 36
36 37
37char *luaL_openspace (lua_State *L, int size) { 38char *luaL_openspace (lua_State *L, size_t size) {
38 openspace(L, size); 39 openspace(L, size);
39 return L->Mbuffer+L->Mbuffnext; 40 return L->Mbuffer+L->Mbuffnext;
40} 41}
@@ -51,23 +52,23 @@ void luaL_resetbuffer (lua_State *L) {
51} 52}
52 53
53 54
54void luaL_addsize (lua_State *L, int n) { 55void luaL_addsize (lua_State *L, size_t n) {
55 L->Mbuffnext += n; 56 L->Mbuffnext += n;
56} 57}
57 58
58int luaL_getsize (lua_State *L) { 59size_t luaL_getsize (lua_State *L) {
59 return L->Mbuffnext-L->Mbuffbase; 60 return L->Mbuffnext-L->Mbuffbase;
60} 61}
61 62
62int luaL_newbuffer (lua_State *L, int size) { 63size_t luaL_newbuffer (lua_State *L, size_t size) {
63 int old = L->Mbuffbase; 64 size_t old = L->Mbuffbase;
64 openspace(L, size); 65 openspace(L, size);
65 L->Mbuffbase = L->Mbuffnext; 66 L->Mbuffbase = L->Mbuffnext;
66 return old; 67 return old;
67} 68}
68 69
69 70
70void luaL_oldbuffer (lua_State *L, int old) { 71void luaL_oldbuffer (lua_State *L, size_t old) {
71 L->Mbuffnext = L->Mbuffbase; 72 L->Mbuffnext = L->Mbuffbase;
72 L->Mbuffbase = old; 73 L->Mbuffbase = old;
73} 74}