1
0
mirror of https://github.com/lua/lua.git synced 2025-01-14 05:43:00 +08:00

new macro 'luaM_reallocvchar' to allocate arrays of chars (avoids

uneeded tests and respective warnings)
This commit is contained in:
Roberto Ierusalimschy 2014-12-19 11:45:40 -02:00
parent 2b83711fba
commit 6321041058
2 changed files with 9 additions and 3 deletions

7
lmem.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lmem.h,v 1.40 2013/02/20 14:08:21 roberto Exp roberto $
** $Id: lmem.h,v 1.41 2014/10/08 20:25:51 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@ -32,6 +32,11 @@
? luaM_toobig(L) : cast_void(0)) , \
luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
/*
** Arrays of chars do not need any test
*/
#define luaM_reallocvchar(L,b,on,n) luaM_realloc_(L, (b), (on), (n))
#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)

5
lzio.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lzio.h,v 1.27 2013/06/07 14:51:10 roberto Exp roberto $
** $Id: lzio.h,v 1.28 2014/01/31 15:14:22 roberto Exp roberto $
** Buffered streams
** See Copyright Notice in lua.h
*/
@ -37,7 +37,8 @@ typedef struct Mbuffer {
#define luaZ_resizebuffer(L, buff, size) \
(luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
((buff)->buffer = cast(char *, luaM_reallocvchar(L, (buff)->buffer, \
(buff)->buffsize, size)), \
(buff)->buffsize = size)
#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)