As suggested by the last patch's notes, I split the endpoint allocation code
into its own function.