added a macro to check whether memory is allocated sucessfully