I wonder if you need to pass a reference of a pointer here. otherwise, an updated pointer `loc_vec` is not returned to where calling this function.