xl: free the libxl context before exit
authorIan Campbell <ian.campbell@citrix.com>
Fri, 30 Jul 2010 14:15:54 +0000 (15:15 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 30 Jul 2010 14:15:54 +0000 (15:15 +0100)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl.c

index 496eb54c331111b3282034087aea4f297cf13a99..85dbca52fae82ad7b23a2fc8a837329d0b405dcd 100644 (file)
@@ -40,6 +40,7 @@ int main(int argc, char **argv)
     int opt = 0;
     char *cmd = 0;
     struct cmd_spec *cspec;
+    int ret;
 
     while ((opt = getopt(argc, argv, "+v")) >= 0) {
         switch (opt) {
@@ -72,12 +73,16 @@ int main(int argc, char **argv)
 
     cspec = cmdtable_lookup(cmd);
     if (cspec)
-        return cspec->cmd_impl(argc, argv);
+        ret = cspec->cmd_impl(argc, argv);
     else if (!strcmp(cmd, "help")) {
         help(argv[optind]);
-        exit(0);
+        ret = 0;
     } else {
         fprintf(stderr, "command not implemented\n");
-        exit(1);
+        ret = 1;
     }
+
+    libxl_ctx_free(&ctx);
+
+    return ret;
 }