From 7db124068f60f8f8208c9f5601407202381e2ecb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 19 Oct 2013 17:32:49 +0200 Subject: [PATCH] ConfigPath: use std::string --- src/ConfigPath.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ConfigPath.cxx b/src/ConfigPath.cxx index 2f3f3ad23..b88de3934 100644 --- a/src/ConfigPath.cxx +++ b/src/ConfigPath.cxx @@ -99,12 +99,11 @@ ParsePath(const char *path, Error &error) ++path; } else { const char *slash = strchr(path, '/'); - char *user = slash != nullptr - ? g_strndup(path, slash - path) - : g_strdup(path); - - home = GetHome(user, error); - g_free(user); + const char *end = slash == nullptr + ? path + strlen(path) + : slash; + const std::string user(path, end); + home = GetHome(user.c_str(), error); if (slash == nullptr) return home;