Common code for allocation of return values