aboutsummaryrefslogtreecommitdiff
path: root/lmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'lmem.c')
-rw-r--r--lmem.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lmem.c b/lmem.c
index 8aeb9974..749fca5b 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: $ 2** $Id: lmem.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
3** Interface to Memory Manager 3** Interface to Memory Manager
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -8,6 +8,7 @@
8#include <stdlib.h> 8#include <stdlib.h>
9 9
10#include "lmem.h" 10#include "lmem.h"
11#include "lstate.h"
11#include "lua.h" 12#include "lua.h"
12 13
13 14
@@ -25,24 +26,21 @@ int luaM_growaux (void **block, unsigned long nelems, int size,
25} 26}
26 27
27 28
28static unsigned long Mbuffsize = 0;
29static char *Mbuffer = NULL;
30
31 29
32void *luaM_buffer (unsigned long size) 30void *luaM_buffer (unsigned long size)
33{ 31{
34 if (size > Mbuffsize) { 32 if (size > L->Mbuffsize) {
35 Mbuffsize = size; 33 L->Mbuffsize = size;
36 Mbuffer = luaM_realloc(Mbuffer, Mbuffsize); 34 L->Mbuffer = luaM_realloc(L->Mbuffer, L->Mbuffsize);
37 } 35 }
38 return Mbuffer; 36 return L->Mbuffer;
39} 37}
40 38
41 39
42void luaM_clearbuffer (void) 40void luaM_clearbuffer (void)
43{ 41{
44 Mbuffsize /= 2; 42 L->Mbuffsize /= 2;
45 Mbuffer = luaM_realloc(Mbuffer, Mbuffsize); 43 L->Mbuffer = luaM_realloc(L->Mbuffer, L->Mbuffsize);
46} 44}
47 45
48 46