Assorted code cleanups
- Variable scope reductions
- Resolve
-Wsign-compare
warnings from gcc - Handle implicit conversion warnings from clang
- Use
calloc
instead ofmalloc
to allocate arrays
-Wsign-compare
warnings from gcccalloc
instead of malloc
to allocate arrays