exit(1) if malloc fails