allocate path inside reconstructpath and return the pointer to the path