diff options
author | Emil Renner Berthing <esmil@mailme.dk> | 2013-12-08 14:23:01 +0100 |
---|---|---|
committer | Emil Renner Berthing <esmil@mailme.dk> | 2013-12-08 15:24:07 +0100 |
commit | 0e339a54b074c7ef5f5cc461c03aac634e92b731 (patch) | |
tree | 7a6da472496b722af5a231d4cba2815056d600a4 /lua/lmem.h | |
parent | c87c5a5619b1ece8ff4522dcfb688191610526f9 (diff) | |
download | lem-0e339a54b074c7ef5f5cc461c03aac634e92b731.tar.gz lem-0e339a54b074c7ef5f5cc461c03aac634e92b731.tar.xz lem-0e339a54b074c7ef5f5cc461c03aac634e92b731.zip |
Lua 5.2.3
Diffstat (limited to 'lua/lmem.h')
-rw-r--r-- | lua/lmem.h | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lmem.h,v 1.38 2011/12/02 13:26:54 roberto Exp $ +** $Id: lmem.h,v 1.40.1.1 2013/04/12 18:48:47 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -14,10 +14,17 @@ #include "lua.h" +/* +** This macro avoids the runtime division MAX_SIZET/(e), as 'e' is +** always constant. +** The macro is somewhat complex to avoid warnings: +** +1 avoids warnings of "comparison has constant result"; +** cast to 'void' avoids warnings of "value unused". +*/ #define luaM_reallocv(L,b,on,n,e) \ - ((cast(size_t, (n)+1) > MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ - (luaM_toobig(L), (void *)0) : \ - luaM_realloc_(L, (b), (on)*(e), (n)*(e))) + (cast(void, \ + (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e))) #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) |