summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-19 11:45:40 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-19 11:45:40 -0200
commit6321041058ec7a597a39df4564f28d5012fd7dfb (patch)
tree0d098bd12ec7123c307b42b2c8d6dc8cadb7a330
parent2b83711fbac0509a40cfb616b9a68bdf683e8471 (diff)
downloadlua-6321041058ec7a597a39df4564f28d5012fd7dfb.tar.gz
lua-6321041058ec7a597a39df4564f28d5012fd7dfb.tar.bz2
lua-6321041058ec7a597a39df4564f28d5012fd7dfb.zip
new macro 'luaM_reallocvchar' to allocate arrays of chars (avoids
uneeded tests and respective warnings)
-rw-r--r--lmem.h7
-rw-r--r--lzio.h5
2 files changed, 9 insertions, 3 deletions
diff --git a/lmem.h b/lmem.h
index d9afa3c6..9caf42fc 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.40 2013/02/20 14:08:21 roberto Exp roberto $ 2** $Id: lmem.h,v 1.41 2014/10/08 20:25:51 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*/
@@ -32,6 +32,11 @@
32 ? luaM_toobig(L) : cast_void(0)) , \ 32 ? luaM_toobig(L) : cast_void(0)) , \
33 luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 33 luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
34 34
35/*
36** Arrays of chars do not need any test
37*/
38#define luaM_reallocvchar(L,b,on,n) luaM_realloc_(L, (b), (on), (n))
39
35#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 40#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
36#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 41#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
37#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 42#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)
diff --git a/lzio.h b/lzio.h
index 6e95fb3d..00778433 100644
--- a/lzio.h
+++ b/lzio.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.h,v 1.27 2013/06/07 14:51:10 roberto Exp roberto $ 2** $Id: lzio.h,v 1.28 2014/01/31 15:14:22 roberto Exp roberto $
3** Buffered streams 3** Buffered streams
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -37,7 +37,8 @@ typedef struct Mbuffer {
37 37
38 38
39#define luaZ_resizebuffer(L, buff, size) \ 39#define luaZ_resizebuffer(L, buff, size) \
40 (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 40 ((buff)->buffer = cast(char *, luaM_reallocvchar(L, (buff)->buffer, \
41 (buff)->buffsize, size)), \
41 (buff)->buffsize = size) 42 (buff)->buffsize = size)
42 43
43#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)