diff options
| -rw-r--r-- | lbuffer.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/lbuffer.c b/lbuffer.c deleted file mode 100644 index 7e0ecdbf..00000000 --- a/lbuffer.c +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | /* | ||
| 2 | ** $Id: lbuffer.c,v 1.14 2000/06/12 13:52:05 roberto Exp roberto $ | ||
| 3 | ** Auxiliary functions for building Lua libraries | ||
| 4 | ** See Copyright Notice in lua.h | ||
| 5 | */ | ||
| 6 | |||
| 7 | |||
| 8 | #include <stdio.h> | ||
| 9 | |||
| 10 | #include "lua.h" | ||
| 11 | |||
| 12 | #include "lauxlib.h" | ||
| 13 | #include "lmem.h" | ||
| 14 | #include "lstate.h" | ||
| 15 | |||
| 16 | |||
| 17 | /*------------------------------------------------------- | ||
| 18 | ** Auxiliary buffer | ||
| 19 | -------------------------------------------------------*/ | ||
| 20 | |||
| 21 | |||
| 22 | /* | ||
| 23 | ** amount of extra space (pre)allocated when buffer is reallocated | ||
| 24 | */ | ||
| 25 | #define EXTRABUFF 32 | ||
| 26 | |||
| 27 | |||
| 28 | #define openspace(L, size) if ((size_t)(size) > L->Mbuffsize-L->Mbuffnext) \ | ||
| 29 | Openspace(L, size) | ||
| 30 | |||
| 31 | static void Openspace (lua_State *L, size_t size) { | ||
| 32 | lint32 newsize = ((lint32)L->Mbuffnext+size+EXTRABUFF)*2; | ||
| 33 | luaM_reallocvector(L, L->Mbuffer, newsize, char); | ||
| 34 | L->Mbuffsize = newsize; | ||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | char *luaL_openspace (lua_State *L, size_t size) { | ||
| 39 | openspace(L, size); | ||
| 40 | return L->Mbuffer+L->Mbuffnext; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | void luaL_addchar (lua_State *L, int c) { | ||
| 45 | openspace(L, 1); | ||
| 46 | L->Mbuffer[L->Mbuffnext++] = (char)c; | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | void luaL_resetbuffer (lua_State *L) { | ||
| 51 | L->Mbuffnext = L->Mbuffbase; | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | void luaL_addsize (lua_State *L, size_t n) { | ||
| 56 | L->Mbuffnext += n; | ||
| 57 | } | ||
| 58 | |||
| 59 | size_t luaL_getsize (lua_State *L) { | ||
| 60 | return L->Mbuffnext-L->Mbuffbase; | ||
| 61 | } | ||
| 62 | |||
| 63 | size_t luaL_newbuffer (lua_State *L, size_t size) { | ||
| 64 | size_t old = L->Mbuffbase; | ||
| 65 | openspace(L, size); | ||
| 66 | L->Mbuffbase = L->Mbuffnext; | ||
| 67 | return old; | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | void luaL_oldbuffer (lua_State *L, size_t old) { | ||
| 72 | L->Mbuffnext = L->Mbuffbase; | ||
| 73 | L->Mbuffbase = old; | ||
| 74 | } | ||
| 75 | |||
| 76 | |||
| 77 | char *luaL_buffer (lua_State *L) { | ||
| 78 | return L->Mbuffer+L->Mbuffbase; | ||
| 79 | } | ||
| 80 | |||
