}
bool GetAppIdByPid(int pid, std::string& name) {
- gchar *con;
-
+ g_autofree gchar *con = NULL;
g_autoptr(GError) error = NULL;
- auto cmdline = g_strdup_printf("/proc/%d/cmdline", pid);
+ g_autofree gchar *cmdline = g_strdup_printf("/proc/%d/cmdline", pid);
if (!g_file_get_contents(cmdline, &con, NULL, &error)) {
TRACKRENDERER_ERROR("error : %s", error->message);
return false;
}
- name = g_path_get_basename(con);
+ g_autofree gchar *basename = g_path_get_basename(con);
+ name = basename;
- g_free(cmdline);
return true;
}