diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-01-28 13:13:26 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-01-28 13:13:26 -0200 |
commit | e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce (patch) | |
tree | 0c8fe009fffa187be71ea3e268daf1a6e29d6d9a /lmem.h | |
parent | 89110986d7a9e81960261ae682780d5fd06dc4ac (diff) | |
download | lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.tar.gz lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.tar.bz2 lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.zip |
janitor work on casts
Diffstat (limited to 'lmem.h')
-rw-r--r-- | lmem.h | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.h,v 1.45 2017/12/07 18:59:52 roberto Exp roberto $ | 2 | ** $Id: lmem.h,v 1.46 2017/12/08 17:28:25 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 | */ |
@@ -29,7 +29,7 @@ | |||
29 | ** avoiding this warning but also this optimization.) | 29 | ** avoiding this warning but also this optimization.) |
30 | */ | 30 | */ |
31 | #define luaM_testsize(n,e) \ | 31 | #define luaM_testsize(n,e) \ |
32 | (sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) | 32 | (sizeof(n) >= sizeof(size_t) && cast_sizet((n)) + 1 > MAX_SIZET/(e)) |
33 | 33 | ||
34 | #define luaM_checksize(L,n,e) \ | 34 | #define luaM_checksize(L,n,e) \ |
35 | (luaM_testsize(n,e) ? luaM_toobig(L) : cast_void(0)) | 35 | (luaM_testsize(n,e) ? luaM_toobig(L) : cast_void(0)) |
@@ -42,13 +42,15 @@ | |||
42 | ** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) | 42 | ** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) |
43 | */ | 43 | */ |
44 | #define luaM_limitN(n,t) \ | 44 | #define luaM_limitN(n,t) \ |
45 | ((cast(size_t, n) > MAX_SIZET/sizeof(t)) ? (MAX_SIZET/sizeof(t)) : (n)) | 45 | ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ |
46 | cast_uint((MAX_SIZET/sizeof(t)))) | ||
47 | |||
46 | 48 | ||
47 | /* | 49 | /* |
48 | ** Arrays of chars do not need any test | 50 | ** Arrays of chars do not need any test |
49 | */ | 51 | */ |
50 | #define luaM_reallocvchar(L,b,on,n) \ | 52 | #define luaM_reallocvchar(L,b,on,n) \ |
51 | cast(char *, luaM_saferealloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) | 53 | cast_charp(luaM_saferealloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) |
52 | 54 | ||
53 | #define luaM_freemem(L, b, s) luaM_free_(L, (b), (s)) | 55 | #define luaM_freemem(L, b, s) luaM_free_(L, (b), (s)) |
54 | #define luaM_free(L, b) luaM_free_(L, (b), sizeof(*(b))) | 56 | #define luaM_free(L, b) luaM_free_(L, (b), sizeof(*(b))) |
@@ -66,8 +68,8 @@ | |||
66 | luaM_limitN(limit,t),e))) | 68 | luaM_limitN(limit,t),e))) |
67 | 69 | ||
68 | #define luaM_reallocvector(L, v,oldn,n,t) \ | 70 | #define luaM_reallocvector(L, v,oldn,n,t) \ |
69 | (cast(t *, luaM_realloc_(L, v, cast(size_t, oldn) * sizeof(t), \ | 71 | (cast(t *, luaM_realloc_(L, v, cast_sizet(oldn) * sizeof(t), \ |
70 | cast(size_t, n) * sizeof(t)))) | 72 | cast_sizet(n) * sizeof(t)))) |
71 | 73 | ||
72 | #define luaM_shrinkvector(L,v,size,fs,t) \ | 74 | #define luaM_shrinkvector(L,v,size,fs,t) \ |
73 | ((v)=cast(t *, luaM_shrinkvector_(L, v, &(size), fs, sizeof(t)))) | 75 | ((v)=cast(t *, luaM_shrinkvector_(L, v, &(size), fs, sizeof(t)))) |