Clang's static analyzer noticed the result of realloc was being
assigned to a pointer of a different type than was used to calculate
the new size. We can make things simpler and more idiomatic here by
using the correct pointer type and letting C's pointer arithmetic
automatically handle some multiplication.
We also use the distributive property here to simplify the calculation
for memset.