buf_size: first get the size in bytes then convert to elements
This is a cleanup and reduces the number of lines needed.
get_array_size_bytes() was already handling some things as a special case
because it wanted to avoid rounding errors from converting from
bytes -> elements -> bytes. Using bytes first and handling elements as
a special case is a more logical in some ways.
This also fixes the issue of casting. We first get the number of bytes and
then we calculate the number of elements.
Also I'm not sure why get_array_size_bytes() queries the DB but
get_array_size() did not query the DB. But this changes that as well.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>