Move memory allocation to parsePath