aboutsummaryrefslogtreecommitdiff
path: root/lmem.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-12-26 16:46:09 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-12-26 16:46:09 -0200
commit8c49e198654567f770a7d5081b886a7c35201d81 (patch)
tree8c1de3e885ef138574e51a8868f175feeaab71e2 /lmem.h
parent6af005ec20323defd2a5ead01e2d389462884d04 (diff)
downloadlua-8c49e198654567f770a7d5081b886a7c35201d81.tar.gz
lua-8c49e198654567f770a7d5081b886a7c35201d81.tar.bz2
lua-8c49e198654567f770a7d5081b886a7c35201d81.zip
explicit control of size for growing vectors
Diffstat (limited to 'lmem.h')
-rw-r--r--lmem.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/lmem.h b/lmem.h
index 8147de5c..c2ee8213 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.16 2000/10/30 16:29:59 roberto Exp roberto $ 2** $Id: lmem.h,v 1.17 2000/11/24 17:39:56 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*/
@@ -14,17 +14,17 @@
14#include "lua.h" 14#include "lua.h"
15 15
16void *luaM_realloc (lua_State *L, void *oldblock, luint32 size); 16void *luaM_realloc (lua_State *L, void *oldblock, luint32 size);
17void *luaM_growaux (lua_State *L, void *block, size_t nelems, 17void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem,
18 int inc, size_t size, const char *errormsg, 18 int limit, const char *errormsg);
19 size_t limit);
20 19
21#define luaM_free(L, b) luaM_realloc(L, (b), 0) 20#define luaM_free(L, b) luaM_realloc(L, (b), 0)
22#define luaM_malloc(L, t) luaM_realloc(L, NULL, (t)) 21#define luaM_malloc(L, t) luaM_realloc(L, NULL, (t))
23#define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t))) 22#define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t)))
24#define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, (n)*(luint32)sizeof(t))) 23#define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, (n)*(luint32)sizeof(t)))
25 24
26#define luaM_growvector(L, v,nelems,inc,t,e,l) \ 25#define luaM_growvector(L,v,nelems,size,t,limit,e) \
27 ((v)=(t *)luaM_growaux(L, v,nelems,inc,sizeof(t),e,l)) 26 if (((nelems)+1) > (size)) \
27 ((v)=(t *)luaM_growaux(L,v,&(size),sizeof(t),limit,e))
28 28
29#define luaM_reallocvector(L, v,n,t) \ 29#define luaM_reallocvector(L, v,n,t) \
30 ((v)=(t *)luaM_realloc(L, v,(n)*(luint32)sizeof(t))) 30 ((v)=(t *)luaM_realloc(L, v,(n)*(luint32)sizeof(t)))