diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-24 10:54:49 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-24 10:54:49 -0300 |
commit | ef62b340e0a6b7b18931000dcbb19c4703bfe0e8 (patch) | |
tree | d9d995116a8a686b798d1b625b06ead26f28ba58 /lbuffer.c | |
parent | 5c2dd7a9e0a5b871a71ba66c4683cd88fe4f5aa4 (diff) | |
download | lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.tar.gz lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.tar.bz2 lua-ef62b340e0a6b7b18931000dcbb19c4703bfe0e8.zip |
code cleaner for 16 bits.
Diffstat (limited to 'lbuffer.c')
-rw-r--r-- | lbuffer.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -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 | ||
31 | static void Openspace (lua_State *L, int size) { | 31 | static 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 | ||
37 | char *luaL_openspace (lua_State *L, int size) { | 38 | char *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 | ||
54 | void luaL_addsize (lua_State *L, int n) { | 55 | void luaL_addsize (lua_State *L, size_t n) { |
55 | L->Mbuffnext += n; | 56 | L->Mbuffnext += n; |
56 | } | 57 | } |
57 | 58 | ||
58 | int luaL_getsize (lua_State *L) { | 59 | size_t luaL_getsize (lua_State *L) { |
59 | return L->Mbuffnext-L->Mbuffbase; | 60 | return L->Mbuffnext-L->Mbuffbase; |
60 | } | 61 | } |
61 | 62 | ||
62 | int luaL_newbuffer (lua_State *L, int size) { | 63 | size_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 | ||
70 | void luaL_oldbuffer (lua_State *L, int old) { | 71 | void 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 | } |