aboutsummaryrefslogtreecommitdiff
path: root/lmem.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-12-28 10:55:41 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-12-28 10:55:41 -0200
commit0183b8030c80f57b87874ff7867ccdb172d9d3dc (patch)
tree1033b5a84489a2f1f1bd210b1b120155cd7aeed7 /lmem.h
parent8c49e198654567f770a7d5081b886a7c35201d81 (diff)
downloadlua-0183b8030c80f57b87874ff7867ccdb172d9d3dc.tar.gz
lua-0183b8030c80f57b87874ff7867ccdb172d9d3dc.tar.bz2
lua-0183b8030c80f57b87874ff7867ccdb172d9d3dc.zip
`free' gets size of the block: complete control over memory use
Diffstat (limited to 'lmem.h')
-rw-r--r--lmem.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/lmem.h b/lmem.h
index c2ee8213..d33473c7 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.17 2000/11/24 17:39:56 roberto Exp roberto $ 2** $Id: lmem.h,v 1.18 2000/12/26 18:46:09 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*/
@@ -13,21 +13,29 @@
13#include "llimits.h" 13#include "llimits.h"
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 oldsize,
17 luint32 size);
18
17void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem, 19void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem,
18 int limit, const char *errormsg); 20 int limit, const char *errormsg);
19 21
20#define luaM_free(L, b) luaM_realloc(L, (b), 0) 22#define luaM_free(L, b, s) luaM_realloc(L, (b), (s), 0)
21#define luaM_malloc(L, t) luaM_realloc(L, NULL, (t)) 23#define luaM_freelem(L, b, t) luaM_realloc(L, (b), sizeof(t), 0)
24#define luaM_freearray(L, b, n, t) luaM_realloc(L, (b), \
25 ((luint32)(n)*(luint32)sizeof(t)), 0)
26
27#define luaM_malloc(L, t) luaM_realloc(L, NULL, 0, (t))
22#define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t))) 28#define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t)))
23#define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, (n)*(luint32)sizeof(t))) 29#define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, \
30 (luint32)(n)*(luint32)sizeof(t)))
24 31
25#define luaM_growvector(L,v,nelems,size,t,limit,e) \ 32#define luaM_growvector(L,v,nelems,size,t,limit,e) \
26 if (((nelems)+1) > (size)) \ 33 if (((nelems)+1) > (size)) \
27 ((v)=(t *)luaM_growaux(L,v,&(size),sizeof(t),limit,e)) 34 ((v)=(t *)luaM_growaux(L,v,&(size),sizeof(t),limit,e))
28 35
29#define luaM_reallocvector(L, v,n,t) \ 36#define luaM_reallocvector(L, v,oldn,n,t) \
30 ((v)=(t *)luaM_realloc(L, v,(n)*(luint32)sizeof(t))) 37 ((v)=(t *)luaM_realloc(L, v,(luint32)(oldn)*(luint32)sizeof(t), \
38 (luint32)(n)*(luint32)sizeof(t)))
31 39
32 40
33#ifdef LUA_DEBUG 41#ifdef LUA_DEBUG