dmime: Split the segment object creation into a separate helper.