aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxlutil.h
diff options
context:
space:
mode:
authorGianni Tedesco <gianni.tedesco@citrix.com>2010-09-09 17:56:11 +0100
committerGianni Tedesco <gianni.tedesco@citrix.com>2010-09-09 17:56:11 +0100
commit73de3694a9c11900aa6e04593b7b90a7548d11da (patch)
treeaf376b7be456efe84ac994580f497841d513ba21 /tools/libxl/libxlutil.h
parentec6adc366137da966bc97691bc50ceb1fe57298c (diff)
downloadxen-73de3694a9c11900aa6e04593b7b90a7548d11da.tar.gz
xen-73de3694a9c11900aa6e04593b7b90a7548d11da.tar.bz2
xen-73de3694a9c11900aa6e04593b7b90a7548d11da.zip
libxl, xl: don't free string literals in config structure
The function init_dm_info() is initialising some strings from literals. This is bad juju because when the destructor is called we cannot know if the string literal was overridden with a strdup()'d value. Therefore strdup values in the initialiser then introduce and use the function libxlu_cfg_replace_string() which free's whatever is set before strdupping the new value on top of it. The rule for the new call should be clear due to const vs. non-const arguments - changing the behaviour of libxlu_cfg_get_string() would cause more complexity than it saves. [ fixed up for stray ! sign -iwj ] Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxlutil.h')
-rw-r--r--tools/libxl/libxlutil.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/libxl/libxlutil.h b/tools/libxl/libxlutil.h
index 0262e55eef..6c992a2c0f 100644
--- a/tools/libxl/libxlutil.h
+++ b/tools/libxl/libxlutil.h
@@ -46,6 +46,7 @@ void xlu_cfg_destroy(XLU_Config*);
*/
int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **value_r);
+int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, char **value_r); /* free/strdup version */
int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r);
int xlu_cfg_get_list(const XLU_Config*, const char *n,