Fix code styling.

1)Use sizeof(varname) instead of type.
2)Use c++ style casts.
Fix array size.

We decrement 1 from cursor array size, which seems un-necessary
as we iterate over for loop starting from 0. This patch fixes
the issue.