Make pass-by-reference explicit by using pointers
commitc911d964e5c58cbee2131416fcb6e666df2e092c
authorTobias Grosser <tobias@grosser.es>
Thu, 6 Aug 2015 17:46:46 +0000 (6 19:46 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 6 Aug 2015 17:58:25 +0000 (6 19:58 +0200)
treea7575be93c1900129e03eb45640f4d39e99fdd9e
parenta184f87704746ba1b358358fb4fa2564280eb4eb
Make pass-by-reference explicit by using pointers

GMP's mpz_t automatically decays to pointer and IMath's mp_int is a
pointer, therefore changing them in a function body always also changes
the argument of the function's caller.  With an isl_int implementation
without pointer semantics (as in imath-32) this is not the case and the
value change is not visible outside of the function.

The parameters g, fl and fu of function construct_test_ineq are
allocated and free'd by its caller, hence we pass pointers to these
locations instead of the values themselves.  Otherwise, the values may get
promoted to a big representation inside the function and the memory
allocated in that conversion would not get freed, resulting in a memory
leak.  Similarly, if the function is passed in an integer in big
representation (in g), then double frees can occur as memory is freed
first inside the function and then later on outside again.

8528f07 (Make pass-by-reference explicit by using pointers,
Tue May 26 15:02:33 2015 +0200) and a1e44f0 (Make pass-by-reference
explicit by using pointer, Tue Jun 30 16:59:45 2015 +0200) fix
similar issues in isl_int_gcdext and row_cmp.

Signed-off-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map_simplify.c