eliminated code related to the handling of RS allocators (now done automatically inside the library)

This commit is contained in:
Luis Peñaranda 2009-12-23 12:01:58 +00:00
parent 2e17c21b01
commit d96f41a2fb
6 changed files with 1 additions and 114 deletions

View File

@ -1 +1,2 @@
include/CGAL/RS/memory.h
include/CGAL/RS/refine_1.h

View File

@ -30,9 +30,6 @@
#include <mpfi.h>
#include <boost/operators.hpp>
#include <boost/shared_ptr.hpp>
#ifdef CGAL_USE_OLD_RS3
# include <CGAL/RS/memory.h>
#endif
namespace CGAL{
@ -63,13 +60,6 @@ class RS_polynomial_1:
void *(*_allocf)(size_t);
void *(*_reallocf)(void*,size_t,size_t);
void (*_freef)(void*,size_t);
#ifdef CGAL_USE_OLD_RS3
// in case of using rs3, _gc_address stores the
// address of the memory zone used to allocate this
// polynomial (which is generally one of the two
// garbage collectors, rs2 or rs3)
gc_session *_gc_address;
#endif
void fetch_gmp_functions();
public:
// copy constructor and copy assignement operator
@ -140,9 +130,6 @@ class RS_polynomial_1:
template<class T>RS_polynomial_1& operator*=(const T&);
template<class T>RS_polynomial_1& operator/=(const T&);
template<class T>RS_polynomial_1 operator/(const T&)const;
#ifdef CGAL_USE_OLD_RS3
gc_session *get_gc_address() const;
#endif
};
} // namespace CGAL

View File

@ -32,28 +32,14 @@ void RS_polynomial_1::create_storage(int size){
inline
void RS_polynomial_1::free_storage(){
#ifdef CGAL_USE_OLD_RS3
gc_session *old_address;
#endif
void *(*af)(size_t);
void *(*rf)(void*,size_t,size_t);
void (*ff)(void*,size_t);
mp_get_memory_functions(&af,&rf,&ff);
mp_set_memory_functions(_allocf,_reallocf,_freef);
#ifdef CGAL_USE_OLD_RS3
old_address=_gc_address;
//std::cout<<"set _gc_address to "<<_gc_address<<std::flush;
set_gc_session(_gc_address);
//std::cout<<" ok"<<std::endl;
#endif
for(int i=0;i<_degree+1;++i)
mpz_clear(coef(i));
mp_set_memory_functions(af,rf,ff);
#ifdef CGAL_USE_OLD_RS3
//std::cout<<"set _gc_address to "<<old_address<<std::flush;
set_gc_session(old_address);
//std::cout<<" ok"<<std::endl;
#endif
(*_freef)(_coef,sizeof(mpz_t)*_capacity);
_capacity=0;
}
@ -61,16 +47,6 @@ void RS_polynomial_1::free_storage(){
inline
void RS_polynomial_1::fetch_gmp_functions(){
mp_get_memory_functions(&_allocf,&_reallocf,&_freef);
#ifdef CGAL_USE_OLD_RS3
if(_allocf==rs3_rs_alloc){
//std::cout<<"alloc by rs3: "<<std::flush;
_gc_address=&rs3_gc_session;
}else{
//std::cout<<"alloc by something else: "<<std::flush;
_gc_address=&rs_default_gc_session;
}
//std::cout<<_gc_address<<std::endl;
#endif
}
//////////////////////
@ -296,13 +272,6 @@ RS_polynomial_1::times_monomial(mpz_srcptr c,int p)const{
return r;
}
#ifdef CGAL_USE_OLD_RS3
inline
gc_session* RS_polynomial_1::get_gc_address() const{
return _gc_address;
}
#endif
} // namespace CGAL
#endif // CGAL_RS_POLYNOMIAL_1_MEMBER_H

View File

@ -26,16 +26,6 @@
#include <CGAL/RS/solve_1.h>
#include <CGAL/RS/ugcd.h>
#include <rs_exports.h>
#ifdef CGAL_USE_OLD_RS3
extern "C"{
# define RS_I32 int
# include <rs_export.h>
# ifdef CGAL_USE_RS3
# include <rs_gc.h>
# endif
}
# include <CGAL/RS/memory.h>
#endif
namespace CGAL{
@ -48,9 +38,6 @@ public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1>{
const RS_polynomial_1 &p2)const{
int dr,d1,d2;
mpz_t * r_z;
#ifdef CGAL_USE_OLD_RS3
init_rs3();
#endif
d1=p1.get_degree();
d2=p2.get_degree();
dr=rs3_up_mz_gcd(
@ -60,13 +47,6 @@ public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1>{
(const mpz_t*)p2.get_coefs(),
d2);
RS_polynomial_1 *result=new RS_polynomial_1(&r_z,dr);
#ifdef CGAL_USE_OLD_RS3
done_with_rs3();
mp_set_memory_functions(
__cgalrs_allocate_func,
__cgalrs_reallocate_func,
__cgalrs_free_func);
#endif
return *result;
}
};
@ -392,21 +372,11 @@ public std::unary_function<RS_polynomial_1,RS_polynomial_1*>{
if(P.get_degree()){
int d_sfp;
mpz_t* sfp_z;
#ifdef CGAL_USE_OLD_RS3
init_rs3();
#endif
d_sfp=rs3_up_mz_sfp(
&sfp_z,
(const mpz_t*)P.get_coefs(),
P.get_degree());
RS_polynomial_1 *result=new RS_polynomial_1(&sfp_z,d_sfp);
#ifdef CGAL_USE_OLD_RS3
done_with_rs3();
mp_set_memory_functions(
__cgalrs_allocate_func,
__cgalrs_reallocate_func,
__cgalrs_free_func);
#endif
return result;
}else
return (new RS_polynomial_1(

View File

@ -21,9 +21,6 @@
#include <CGAL/Polynomial.h>
#include <CGAL/RS/polynomial_1.h>
#ifdef CGAL_USE_OLD_RS3
# include <CGAL/RS/memory.h>
#endif
namespace CGAL{

View File

@ -29,11 +29,6 @@
#include <CGAL/RS/polynomial_1.h>
#include <CGAL/RS/algebraic_1.h>
#include <rs_exports.h>
#ifdef CGAL_USE_OLD_RS3
# include <CGAL/RS/memory.h>
# define RS_I32 int
# include <rs_export.h>
#endif
namespace CGAL{
@ -53,34 +48,6 @@ inline void init_solver(){
}
}
#ifdef CGAL_USE_OLD_RS3
inline void init_rs3(){
static bool first=true;
if(first){
first=false;
init_solver();
rs_set_usr_memory_fncts
(rs3_rs_alloc,rs3_rs_realloc,rs3_rs_free);
mp_set_memory_functions
(rs3_rs_alloc,rs3_rs_gmp_realloc,rs3_rs_gmp_free);
set_gc_session(&rs3_gc_session);
rs_internal_init();
}else{
rs_set_usr_memory_fncts
(rs3_rs_alloc,rs3_rs_realloc,rs3_rs_free);
mp_set_memory_functions
(rs3_rs_alloc,rs3_rs_gmp_realloc,rs3_rs_gmp_free);
set_gc_session(&rs3_gc_session);
rs_internal_reset();
}
}
inline void done_with_rs3(){
mp_set_memory_functions(RS_gmpalloc,RS_gmprealloc,RS_gmpfree);
set_gc_session(&rs_default_gc_session);
}
#endif
// reset RS memory
inline void reset_solver(){
rs_reset_all();
@ -192,10 +159,6 @@ inline int solve_1(
mpfi_ptr *x,
const RS_polynomial_1 &p1,
unsigned int prec=CGAL_RS_DEF_PREC){
#ifdef CGAL_USE_OLD_RS3
set_gc_session(p1.get_gc_address());
//set_gc_session(&rs3_gc_session);
#endif
rs_reset_all();
create_rs_upoly(p1.get_coefs(),p1.get_degree(),rs_get_default_up());
set_rs_precisol(prec);