Change C casts to C++ ones

Some were kept for compatibility.

Found with -Wold-style-cast

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2020-04-08 16:56:59 -07:00
committed by ridiculousfish
parent f36c82ce86
commit 0668513138
24 changed files with 61 additions and 51 deletions

View File

@@ -35,16 +35,18 @@ static CharT **make_null_terminated_array_helper(
const std::basic_string<CharT> &str = argv.at(i);
*pointers++ = strings; // store the current string pointer into self
strings = std::copy(str.begin(), str.end(), strings); // copy the string into strings
*strings++ = (CharT)(0); // each string needs a null terminator
*strings++ = static_cast<CharT>(0); // each string needs a null terminator
}
*pointers++ = nullptr; // array of pointers needs a null terminator
// Make sure we know what we're doing.
assert((unsigned char *)pointers - base == (std::ptrdiff_t)pointers_allocation_len);
assert((unsigned char *)strings - (unsigned char *)pointers ==
(std::ptrdiff_t)strings_allocation_len);
assert((unsigned char *)strings - base ==
(std::ptrdiff_t)(pointers_allocation_len + strings_allocation_len));
assert(reinterpret_cast<unsigned char *>(pointers) - base ==
static_cast<std::ptrdiff_t>(pointers_allocation_len));
assert(reinterpret_cast<unsigned char *>(strings) -
reinterpret_cast<unsigned char *>(pointers) ==
static_cast<std::ptrdiff_t>(strings_allocation_len));
assert(reinterpret_cast<unsigned char *>(strings) - base ==
static_cast<std::ptrdiff_t>(pointers_allocation_len + strings_allocation_len));
return reinterpret_cast<CharT **>(base);
}