Why not have _get_runtime_dir return a static string pointer instead? It avoids a copy in the (common) case where XDG_RUNTIME_DIR is set, and only leaks memory on exit if XDG_RUNTIME_DIR is not set.