Optimal allocation of resources explains interspecific life-history patterns in animals with indeterminate growth