aboutsummaryrefslogtreecommitdiff
path: root/lmem.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-11-14 15:21:34 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-11-14 15:21:34 -0200
commitf993771c70f5b0f63562259f7353d675275e8774 (patch)
treeb08b15f01e75e45cd9ceafeb979a14cc38c51d16 /lmem.h
parent52f9ccd298b3ff63f3ce3303d1b975ff8093f809 (diff)
downloadlua-f993771c70f5b0f63562259f7353d675275e8774.tar.gz
lua-f993771c70f5b0f63562259f7353d675275e8774.tar.bz2
lua-f993771c70f5b0f63562259f7353d675275e8774.zip
avoids warning with 'clang' + comment explaining macro
Diffstat (limited to 'lmem.h')
-rw-r--r--lmem.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/lmem.h b/lmem.h
index 90dabd66..0eba1518 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.37 2011/11/30 12:42:49 roberto Exp roberto $ 2** $Id: lmem.h,v 1.38 2011/12/02 13:26:54 roberto Exp $
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,10 +14,17 @@
14#include "lua.h" 14#include "lua.h"
15 15
16 16
17/*
18** This macro avoids the runtime division MAX_SIZET/(e), as 'e' is
19** always constant.
20** The macro is somewhat complex to avoid warnings:
21** +1 avoids warnings of "comparsion has constant result";
22** cast to 'void' avoids warnings of "value unused".
23*/
17#define luaM_reallocv(L,b,on,n,e) \ 24#define luaM_reallocv(L,b,on,n,e) \
18 ((cast(size_t, (n)+1) > MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 25 (cast(void, \
19 (luaM_toobig(L), (void *)0) : \ 26 (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \
20 luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 27 luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
21 28
22#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 29#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
23#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 30#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)