[Profiler][Trivial] Add null handling to `AppendOnlyList::copy` memcpy path. (#83963)
It is apparently undefined behavior to do pointer arithmetic on nullptr. In the case of AppendOnlyList, `next_` will only be null if `end_` is also null and thus the `memcpy` path will only be triggered if `n == 0`. Nonetheless, it is UB to `memcpy(0, 0, 0)`
The extra null check is in a `C10_LIKELY` block so the extra cost should be negligible, and indeed after dusting off the component microbenchmarks there's no observable difference.
Differential Revision: [D38969443](https://our.internmc.facebook.com/intern/diff/D38969443/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83963
Approved by: https://github.com/slgong-fb