Mostly to allow leak-free early exiting from functions generating the tooltip data, otherwise cleanups have to be duplicated. But using smart pointers is good practice in general. Also use references instead of pointers, to indicate that null is not an expected value.