aboutsummaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorWei Jiangang <weijg.fnst@cn.fujitsu.com>2016-04-07 10:46:24 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2016-07-17 09:59:21 +0200
commit55ad781ca7fcaed19e04554b558727206d638a99 (patch)
tree3238b42fb35446849c71a6d5baafee314117a0f9 /os-posix.c
parent6b92bbfe812746fe7841a24c24e6460f5359ce72 (diff)
downloadqemu-55ad781ca7fcaed19e04554b558727206d638a99.zip
qemu-55ad781ca7fcaed19e04554b558727206d638a99.tar.gz
qemu-55ad781ca7fcaed19e04554b558727206d638a99.tar.bz2
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>
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/os-posix.c b/os-posix.c
index 3755265..c6ddb7d 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -89,7 +89,7 @@ char *os_find_datadir(void)
if (exec_dir == NULL) {
return NULL;
}
- dir = dirname(exec_dir);
+ dir = g_path_get_dirname(exec_dir);
max_len = strlen(dir) +
MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
@@ -103,6 +103,7 @@ char *os_find_datadir(void)
}
}
+ g_free(dir);
g_free(exec_dir);
return res;
}