Added Error Handling

Added error handling for asprintf and added GNU SOURCE define that
removes a warning related to asprintf.