Style and don't check if FOO free(FOO)
Remove malloc and realloc casts.