]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commit
libxl: Use libxl_strdup instead of strdup on libxl_version_info
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 26 Jan 2016 21:30:57 +0000 (16:30 -0500)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 3 Feb 2016 11:17:01 +0000 (11:17 +0000)
commitd531444b6e4575b59977b8ead910baf12ec0de77
tree2f471d6161259b4c7b43a56b59fb7fd7d64d778e
parent4a7abc58ff74ff54cf2ad490d5b279a0e9aad9eb
libxl: Use libxl_strdup instead of strdup on libxl_version_info

The change is simple replace of raw strdup with a libxl variant.
The benefit of that is the libxl variant has the extra
behaviour of abort-on-alloc-fail - and will improve error handling.

libxl_version_info is a bit odd - it is a public function and as libxl.h
mentions - the callers of libxl_ public function needs to call the appropiate
_dispose() function.

"However libxl_get_version_info() is special and returns a cached
result from the ctx which cannot and should not be freed (as evidenced
by it returning a const struct). This data is freed in libxl_ctx_free()
by calling libxl_version_info_dispose(). This is why none of the callers
remember to free -- they shouldn't be doing so." (Ian Campbell)

So the patch makes sure to use the NOGC.

Suggested-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl.c