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 /ltests.c | |
parent | 89110986d7a9e81960261ae682780d5fd06dc4ac (diff) | |
download | lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.tar.gz lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.tar.bz2 lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.zip |
janitor work on casts
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.239 2018/01/09 11:21:41 roberto Exp $ | 2 | ** $Id: ltests.c,v 2.239 2018/01/09 11:24:12 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -110,7 +110,7 @@ static void freeblock (Memcontrol *mc, Header *block) { | |||
110 | size_t size = block->d.size; | 110 | size_t size = block->d.size; |
111 | int i; | 111 | int i; |
112 | for (i = 0; i < MARKSIZE; i++) /* check marks after block */ | 112 | for (i = 0; i < MARKSIZE; i++) /* check marks after block */ |
113 | lua_assert(*(cast(char *, block + 1) + size + i) == MARK); | 113 | lua_assert(*(cast_charp(block + 1) + size + i) == MARK); |
114 | mc->objcount[block->d.type]--; | 114 | mc->objcount[block->d.type]--; |
115 | fillmem(block, sizeof(Header) + size + MARKSIZE); /* erase block */ | 115 | fillmem(block, sizeof(Header) + size + MARKSIZE); /* erase block */ |
116 | free(block); /* actually free block */ | 116 | free(block); /* actually free block */ |
@@ -161,10 +161,10 @@ void *debug_realloc (void *ud, void *b, size_t oldsize, size_t size) { | |||
161 | freeblock(mc, block); /* erase (and check) old copy */ | 161 | freeblock(mc, block); /* erase (and check) old copy */ |
162 | } | 162 | } |
163 | /* initialize new part of the block with something weird */ | 163 | /* initialize new part of the block with something weird */ |
164 | fillmem(cast(char *, newblock + 1) + commonsize, size - commonsize); | 164 | fillmem(cast_charp(newblock + 1) + commonsize, size - commonsize); |
165 | /* initialize marks after block */ | 165 | /* initialize marks after block */ |
166 | for (i = 0; i < MARKSIZE; i++) | 166 | for (i = 0; i < MARKSIZE; i++) |
167 | *(cast(char *, newblock + 1) + size + i) = MARK; | 167 | *(cast_charp(newblock + 1) + size + i) = MARK; |
168 | newblock->d.size = size; | 168 | newblock->d.size = size; |
169 | newblock->d.type = type; | 169 | newblock->d.type = type; |
170 | mc->total += size; | 170 | mc->total += size; |
@@ -919,8 +919,8 @@ static int upvalue (lua_State *L) { | |||
919 | 919 | ||
920 | 920 | ||
921 | static int newuserdata (lua_State *L) { | 921 | static int newuserdata (lua_State *L) { |
922 | size_t size = cast(size_t, luaL_checkinteger(L, 1)); | 922 | size_t size = cast_sizet(luaL_checkinteger(L, 1)); |
923 | char *p = cast(char *, lua_newuserdata(L, size)); | 923 | char *p = cast_charp(lua_newuserdata(L, size)); |
924 | while (size--) *p++ = '\0'; | 924 | while (size--) *p++ = '\0'; |
925 | return 1; | 925 | return 1; |
926 | } | 926 | } |
@@ -928,7 +928,7 @@ static int newuserdata (lua_State *L) { | |||
928 | 928 | ||
929 | static int pushuserdata (lua_State *L) { | 929 | static int pushuserdata (lua_State *L) { |
930 | lua_Integer u = luaL_checkinteger(L, 1); | 930 | lua_Integer u = luaL_checkinteger(L, 1); |
931 | lua_pushlightuserdata(L, cast(void *, cast(size_t, u))); | 931 | lua_pushlightuserdata(L, cast_voidp(cast_sizet(u))); |
932 | return 1; | 932 | return 1; |
933 | } | 933 | } |
934 | 934 | ||
@@ -959,7 +959,7 @@ static int s2d (lua_State *L) { | |||
959 | 959 | ||
960 | static int d2s (lua_State *L) { | 960 | static int d2s (lua_State *L) { |
961 | double d = luaL_checknumber(L, 1); | 961 | double d = luaL_checknumber(L, 1); |
962 | lua_pushlstring(L, cast(char *, &d), sizeof(d)); | 962 | lua_pushlstring(L, cast_charp(&d), sizeof(d)); |
963 | return 1; | 963 | return 1; |
964 | } | 964 | } |
965 | 965 | ||
@@ -1277,7 +1277,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
1277 | } | 1277 | } |
1278 | else if EQ("func2num") { | 1278 | else if EQ("func2num") { |
1279 | lua_CFunction func = lua_tocfunction(L1, getindex); | 1279 | lua_CFunction func = lua_tocfunction(L1, getindex); |
1280 | lua_pushnumber(L1, cast(size_t, func)); | 1280 | lua_pushnumber(L1, cast_sizet(func)); |
1281 | } | 1281 | } |
1282 | else if EQ("getfield") { | 1282 | else if EQ("getfield") { |
1283 | int t = getindex; | 1283 | int t = getindex; |
@@ -1422,11 +1422,11 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
1422 | } | 1422 | } |
1423 | else if EQ("rawgetp") { | 1423 | else if EQ("rawgetp") { |
1424 | int t = getindex; | 1424 | int t = getindex; |
1425 | lua_rawgetp(L1, t, cast(void *, cast(size_t, getnum))); | 1425 | lua_rawgetp(L1, t, cast_voidp(cast_sizet(getnum))); |
1426 | } | 1426 | } |
1427 | else if EQ("rawsetp") { | 1427 | else if EQ("rawsetp") { |
1428 | int t = getindex; | 1428 | int t = getindex; |
1429 | lua_rawsetp(L1, t, cast(void *, cast(size_t, getnum))); | 1429 | lua_rawsetp(L1, t, cast_voidp(cast_sizet(getnum))); |
1430 | } | 1430 | } |
1431 | else if EQ("remove") { | 1431 | else if EQ("remove") { |
1432 | lua_remove(L1, getnum); | 1432 | lua_remove(L1, getnum); |
@@ -1511,7 +1511,7 @@ static struct X { int x; } x; | |||
1511 | lua_pushnumber(L1, lua_tonumber(L1, getindex)); | 1511 | lua_pushnumber(L1, lua_tonumber(L1, getindex)); |
1512 | } | 1512 | } |
1513 | else if EQ("topointer") { | 1513 | else if EQ("topointer") { |
1514 | lua_pushnumber(L1, cast(size_t, lua_topointer(L1, getindex))); | 1514 | lua_pushnumber(L1, cast_sizet(lua_topointer(L1, getindex))); |
1515 | } | 1515 | } |
1516 | else if EQ("tostring") { | 1516 | else if EQ("tostring") { |
1517 | const char *s = lua_tostring(L1, getindex); | 1517 | const char *s = lua_tostring(L1, getindex); |
@@ -1725,7 +1725,7 @@ int luaB_opentests (lua_State *L) { | |||
1725 | lua_atpanic(L, &tpanic); | 1725 | lua_atpanic(L, &tpanic); |
1726 | atexit(checkfinalmem); | 1726 | atexit(checkfinalmem); |
1727 | lua_assert(lua_getallocf(L, &ud) == debug_realloc); | 1727 | lua_assert(lua_getallocf(L, &ud) == debug_realloc); |
1728 | lua_assert(ud == cast(void *, &l_memcontrol)); | 1728 | lua_assert(ud == cast_voidp(&l_memcontrol)); |
1729 | lua_setallocf(L, lua_getallocf(L, NULL), ud); | 1729 | lua_setallocf(L, lua_getallocf(L, NULL), ud); |
1730 | luaL_newlib(L, tests_funcs); | 1730 | luaL_newlib(L, tests_funcs); |
1731 | return 1; | 1731 | return 1; |