diff --git a/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.C b/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.C index e48e8e72f39..8d0b9f7009a 100644 --- a/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.C +++ b/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.C @@ -128,10 +128,13 @@ Algebraic_1::Algebraic_1 (const CGAL::Gmpq &l, const CGAL::Gmpq &r) { mpfi_interv_q (mpfi (), l.mpq(), r.mpq()); }; -Algebraic_1::Algebraic_1 (const mpfi_t &i) { - mpfi_set (mpfi (), i); +// here, the constructor copies the address of the mpfi, not the contents +Algebraic_1::Algebraic_1 (mpfi_t &i) { + mpfi_clear(mpfi()); + *mpfi()=*i; }; +// this is a copy constructor that copies everything, including the mpfi Algebraic_1::Algebraic_1 (const Algebraic_1 &i) { mpfi_set (mpfi (), i.mpfi ()); set_pol (i.pol ()); @@ -141,9 +144,10 @@ Algebraic_1::Algebraic_1 (const Algebraic_1 &i) { }; // interesting constructor -Algebraic_1::Algebraic_1 (const mpfi_t &i, const Rational_polynomial_1 &p, +Algebraic_1::Algebraic_1 (const mpfi_ptr &i, const Rational_polynomial_1 &p, const int n, const int m, const int rsp) { - mpfi_set (mpfi (), i); + mpfi_clear(mpfi()); + *mpfi()=*i; set_pol (p); set_nr (n); set_mult (m); @@ -551,7 +555,6 @@ Algebraic_1 Algebraic_1::operator- () const { mpfi_init (n); mpfi_neg (n, mpfi ()); Algebraic_1 ret (n); - mpfi_clear (n); return ret; }; @@ -560,7 +563,6 @@ Algebraic_1 Algebraic_1::operator+ (const Algebraic_1 &n2) const { mpfi_init (n); mpfi_add (n, mpfi (), n2.mpfi()); Algebraic_1 ret (n); - mpfi_clear (n); return ret; }; @@ -573,7 +575,6 @@ Algebraic_1 Algebraic_1::operator* (const Algebraic_1 &n2) const { mpfi_init (n); mpfi_mul (n, mpfi (), n2.mpfi()); Algebraic_1 ret (n); - mpfi_clear (n); return ret; }; @@ -698,7 +699,6 @@ Algebraic_1 Algebraic_1::operator/ (const Algebraic_1 &n2) const { mpfi_init (n); mpfi_div (n, mpfi (), n2.mpfi()); Algebraic_1 ret (n); - mpfi_clear (n); return ret; }; @@ -719,7 +719,6 @@ Algebraic_1 Algebraic_1::sqrt () const { mpfi_init (s); mpfi_sqrt (s, mpfi ()); Algebraic_1 ret (s); - mpfi_clear (s); return ret; }; diff --git a/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.h b/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.h index 43e6faf0bba..a44058df7ad 100644 --- a/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.h +++ b/Algebraic_kernel_GBRS/include/CGAL/Gbrs_algebraic_1.h @@ -54,7 +54,7 @@ public: int rsprec; Algebraic_1_rep():poly(NULL),nr(-1),mult(-1),rsprec(0){mpfi_init(mpfI);} - ~Algebraic_1_rep () { mpfi_clear (mpfI); } + ~Algebraic_1_rep () {} private: // Make sure it does not get accidentally copied. @@ -107,11 +107,11 @@ public: Algebraic_1 (const mpq_t &, const mpq_t &); Algebraic_1 (const CGAL::Gmpq &, const CGAL::Gmpq &); Algebraic_1 (const CGAL::Gmpz &, const CGAL::Gmpz &); - Algebraic_1 (const mpfi_t &); + Algebraic_1 (mpfi_t &); Algebraic_1 (const Algebraic_1 &); // the only interesting constructor - Algebraic_1 (const mpfi_t &, const Rational_polynomial_1 &, + Algebraic_1 (const mpfi_ptr &, const Rational_polynomial_1 &, const int, const int, const int); Algebraic_1& operator= (const long int); diff --git a/Algebraic_kernel_GBRS/include/CGAL/Gbrs_functors.h b/Algebraic_kernel_GBRS/include/CGAL/Gbrs_functors.h index 91a80833f73..a6bec8ed48f 100644 --- a/Algebraic_kernel_GBRS/include/CGAL/Gbrs_functors.h +++ b/Algebraic_kernel_GBRS/include/CGAL/Gbrs_functors.h @@ -84,7 +84,7 @@ class Solve_1 { bool known_to_be_square_free) const { if (known_to_be_square_free) return res; - mpfi_t *x; + mpfi_ptr *x; int nr; CGAL_assertion_msg (((nr = solve_1 (x, p)) >= 0), "error in resolution"); @@ -92,8 +92,6 @@ class Solve_1 { for (int i=0; i