Changed calls to snprintf to asprintf as per
@eatnumber1's suggestion. Also fixed the style
issues both @eatnumber and @clockfort found