use g_path_get_dirname instead of dirname

Use g_path_get_basename to get the directory components of
a file name, and free its return when no longer needed.

Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
Message-Id: <1459997185-15669-3-git-send-email-weijg.fnst@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Wei Jiangang 2016-04-07 10:46:24 +08:00 committed by Paolo Bonzini
parent 6b92bbfe81
commit 55ad781ca7
2 changed files with 5 additions and 2 deletions

View file

@ -299,9 +299,11 @@ void qemu_init_exec_dir(const char *argv0)
return;
}
}
dir = dirname(p);
dir = g_path_get_dirname(p);
pstrcpy(exec_dir, sizeof(exec_dir), dir);
g_free(dir);
}
char *qemu_get_exec_dir(void)