[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 2/7] gentest: make testidl valgrind clean
Free the JSON string after use to avoid memory leak. With this change testidl is valgrind clean. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/gentest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/libxl/gentest.py b/tools/libxl/gentest.py index 95323d1..849bfc7 100644 --- a/tools/libxl/gentest.py +++ b/tools/libxl/gentest.py @@ -229,7 +229,7 @@ int main(int argc, char **argv) (ty.typename, ty.typename, ty.typename)) f.write(""" int rc; - char *s, *new_s; + char *s, *new_s, *json_string; xentoollog_logger_stdiostream *logger; libxl_ctx *ctx; @@ -323,9 +323,13 @@ int main(int argc, char **argv) f.write(" printf(\"%s -- to JSON:\\n\");\n" % (ty.typename)) for v in ty.values: + f.write(" json_string = %s_to_json(ctx, %s);\n" % \ + (ty.typename, v.name)) f.write(" printf(\"\\t%s = %%d = %%s\", " \ - "%s, %s_to_json(ctx, %s));\n" %\ - (v.valuename, v.name, ty.typename, v.name)) + "%s, json_string);\n" %\ + (v.valuename, v.name)) + f.write(" free(json_string);\n"); + f.write(" json_string = NULL;\n"); f.write("\n") f.write(" printf(\"%s -- from string:\\n\");\n" % (ty.typename)) -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |