isl_bound: plug memory leak
[platform/upstream/isl.git] / pip.c
diff --git a/pip.c b/pip.c
index ae92a81..9f528ad 100644 (file)
--- a/pip.c
+++ b/pip.c
@@ -16,6 +16,7 @@
 #include "isl_scan.h"
 #include "isl_seq.h"
 #include "isl_ilp.h"
+#include <isl_point_private.h>
 
 /* The input of this program is the same as that of the "example" program
  * from the PipLib distribution, except that the "big parameter column"
@@ -39,8 +40,9 @@ struct pip_options {
 };
 
 struct isl_arg pip_options_arg[] = {
-ISL_ARG_CHILD(struct pip_options, isl, "isl", isl_options_arg)
-ISL_ARG_BOOL(struct pip_options, verify, 'T', "verify", 0)
+ISL_ARG_CHILD(struct pip_options, isl, "isl", isl_options_arg, "isl options")
+ISL_ARG_BOOL(struct pip_options, verify, 'T', "verify", 0, NULL)
+ISL_ARG_END
 };
 
 ISL_ARG_DEF(pip_options, struct pip_options, pip_options_arg)
@@ -215,11 +217,10 @@ static int scan_one(struct isl_scan_callback *callback,
        assert(opt);
 
        if (opt->size == 0) {
-               isl_set *sample_set;
-               sample_set = isl_set_from_basic_set(
-                               isl_basic_set_from_vec(sample));
-               assert(isl_set_is_subset(sample_set, sp->empty));
-               isl_set_free(sample_set);
+               isl_point *sample_pnt;
+               sample_pnt = isl_point_alloc(isl_set_get_dim(sp->empty), sample);
+               assert(isl_set_contains_point(sp->empty, sample_pnt));
+               isl_point_free(sample_pnt);
                isl_vec_free(opt);
        } else {
                isl_set *sol;
@@ -313,18 +314,17 @@ int main(int argc, char **argv)
 
        options = pip_options_new_with_defaults();
        assert(options);
-       argc = pip_options_parse(options, argc, argv);
+       argc = pip_options_parse(options, argc, argv, ISL_ARG_ALL);
 
-       ctx = isl_ctx_alloc_with_options(options->isl);
-       options->isl = NULL;
+       ctx = isl_ctx_alloc_with_options(pip_options_arg, options);
 
-       context = isl_basic_set_read_from_file(ctx, stdin, 0, ISL_FORMAT_POLYLIB);
+       context = isl_basic_set_read_from_file(ctx, stdin, 0);
        assert(context);
        n = fscanf(stdin, "%d", &neg_one);
        assert(n == 1);
        assert(neg_one == -1);
        bset = isl_basic_set_read_from_file(ctx, stdin,
-               isl_basic_set_dim(context, isl_dim_set), ISL_FORMAT_POLYLIB);
+               isl_basic_set_dim(context, isl_dim_set));
 
        while (fgets(s, sizeof(s), stdin)) {
                if (strncasecmp(s, "Maximize", 8) == 0)
@@ -360,15 +360,16 @@ int main(int argc, char **argv)
                assert(!rational);
                check_solution(copy, context_copy, set, empty, max);
        } else {
-               isl_set_dump(set, stdout, 0);
-               fprintf(stdout, "no solution:\n");
-               isl_set_dump(empty, stdout, 4);
+               isl_set_print(set, stdout, 0, ISL_FORMAT_ISL);
+               fprintf(stdout, "\n");
+               fprintf(stdout, "no solution: ");
+               isl_set_print(empty, stdout, 0, ISL_FORMAT_ISL);
+               fprintf(stdout, "\n");
        }
 
        isl_set_free(set);
        isl_set_free(empty);
        isl_ctx_free(ctx);
-       free(options);
 
        return 0;
 }