I don't think there is any cleaner solution for that. I would just not copy joint_state->name to a separate variable but would directly reference it or use a reference to avoid copying it. But that's really just a minor thing.