diff --git a/ChangeLog b/ChangeLog index 857fbee..80da006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2005-05-01 Richard B. Kreckel + + Fix crashes in find_univpoly_ring and related functions + * include/cln/modinteger.h: Remove vptr from cl_heap_modint_ring; + remove declaration of cl_class cl_class_modint_ring. + * include/cln/univpoly.h: Remove vptr from cl_heap_univpoly_ring; + remove declaration of cl_class_univpoly_ring. + * include/cln/object.h: cl_class_flags_modint_ring: New #define... + * src/modinteger/cl_MI.cc: ...used in cl_class_modint_ring. + * src/modinteger/cl_MI_fix16.h: No vptr, but static dtor and type flag. + * src/modinteger/cl_MI_fix29.h: Likewise. + * src/modinteger/cl_MI_fix32.h: Likewise. + * src/modinteger/cl_MI_int32.h: Likewise. + * src/modinteger/cl_MI_montgom.h: Likewise. + * src/modinteger/cl_MI_pow2: Likewise. + * src/modinteger/cl_MI_pow2m1.h: Likewise. + * src/modinteger/cl_MI_pow2p1.h: Likewise. + * src/modinteger/cl_MI_std.h: Likewise. + * src/polynomial/elem/cl_UP.cc (cl_make_univpoly_ring): Compare with + cl_class_flags_modint_ring, not with cl_class_modint_ring. + * src/polynomial/elem/cl_UP_GF2.h (cl_class_num_univpoly_ring): New. + * src/polynomial/elem/cl_UP_MI.h (cl_class_modint_univpoly_ring): New. + * src/polynomial/elem/cl_UP_gen.h (cl_class_gen_univpoly_ring): New. + * src/polynomial/elem/cl_UP_number.h (cl_class_num_univpoly_ring): New. + Reported by Ralf Goertz . + 2005-04-29 Richard B. Kreckel Ralf Wildenhues diff --git a/include/cln/modinteger.h b/include/cln/modinteger.h index d339cba..59ae42f 100644 --- a/include/cln/modinteger.h +++ b/include/cln/modinteger.h @@ -349,12 +349,9 @@ public: { return properties.get_property(key); } void add_property (cl_property* new_property) { properties.add_property(new_property); } -// Constructor. +// Constructor / destructor. cl_heap_modint_ring (cl_I m, cl_modint_setops*, cl_modint_addops*, cl_modint_mulops*); -// This class is intented to be subclassable, hence needs a virtual destructor. - virtual ~cl_heap_modint_ring () {} -private: - virtual void dummy (); + ~cl_heap_modint_ring () {} }; #define SUBCLASS_cl_heap_modint_ring() \ SUBCLASS_cl_heap_ring() @@ -363,9 +360,6 @@ private: extern const cl_modint_ring find_modint_ring (const cl_I& m); CL_REQUIRE(cl_MI) -// Runtime typing support. -extern cl_class cl_class_modint_ring; - // Operations on modular integers. diff --git a/include/cln/object.h b/include/cln/object.h index 70faa35..b7353dc 100644 --- a/include/cln/object.h +++ b/include/cln/object.h @@ -168,13 +168,15 @@ struct cl_heap { // Function to destroy the contents of a heap object. typedef void (*cl_heap_destructor_function) (cl_heap* pointer); -// Flags, to be ORed together. +// Flags, may be ORed together. #define cl_class_flags_subclass_complex 1 // all instances belong to cl_N #define cl_class_flags_subclass_real 2 // all instances belong to cl_R #define cl_class_flags_subclass_float 4 // all instances belong to cl_F #define cl_class_flags_subclass_rational 8 // all instances belong to cl_RA #define cl_class_flags_number_ring 16 // all instances are rings whose // elements belong to cl_number +#define cl_class_flags_modint_ring 32 // all instances are rings whose + // elements belong to cl_MI // Function to print an object for debugging, to cerr. typedef void (*cl_heap_dprint_function) (cl_heap* pointer); diff --git a/include/cln/univpoly.h b/include/cln/univpoly.h index 7547c06..39e1f1e 100644 --- a/include/cln/univpoly.h +++ b/include/cln/univpoly.h @@ -340,10 +340,7 @@ public: { properties.add_property(new_property); } // Constructor. cl_heap_univpoly_ring (const cl_ring& r, cl_univpoly_setops*, cl_univpoly_addops*, cl_univpoly_mulops*, cl_univpoly_modulops*, cl_univpoly_polyops*); -// This class is intented to be subclassable, hence needs a virtual destructor. - virtual ~cl_heap_univpoly_ring () {} -private: - virtual void dummy (); + ~cl_heap_univpoly_ring () {} }; #define SUBCLASS_cl_heap_univpoly_ring() \ SUBCLASS_cl_heap_ring() @@ -359,9 +356,6 @@ extern const cl_univpoly_ring find_univpoly_ring (const cl_ring& r, const cl_sym CL_REQUIRE(cl_UP) -// Runtime typing support. -extern cl_class cl_class_univpoly_ring; - // Operations on polynomials. diff --git a/src/modinteger/cl_MI.cc b/src/modinteger/cl_MI.cc index d1cc623..a15b2c3 100644 --- a/src/modinteger/cl_MI.cc +++ b/src/modinteger/cl_MI.cc @@ -27,6 +27,16 @@ CL_PROVIDE(cl_MI) namespace cln { +static void cl_modint_ring_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring*)pointer).~cl_heap_modint_ring(); +} + +cl_class cl_class_modint_ring = { + cl_modint_ring_destructor, + cl_class_flags_modint_ring +}; + cl_heap_modint_ring::cl_heap_modint_ring (cl_I m, cl_modint_setops* setopv, cl_modint_addops* addopv, cl_modint_mulops* mulopv) : setops (setopv), addops (addopv), mulops (mulopv), modulus (m) { @@ -50,20 +60,6 @@ cl_heap_modint_ring::cl_heap_modint_ring (cl_I m, cl_modint_setops* setopv, cl_m } } -static void cl_modint_ring_destructor (cl_heap* pointer) -{ - (*(cl_heap_modint_ring*)pointer).~cl_heap_modint_ring(); -} - -cl_class cl_class_modint_ring = { - cl_modint_ring_destructor, - 0 -}; - -// This tells the compiler to put the `cl_heap_modint_ring' vtable -// into this file. -void cl_heap_modint_ring::dummy () {} - static cl_boolean modint_equal (cl_heap_modint_ring* R, const _cl_MI& x, const _cl_MI& y) { diff --git a/src/modinteger/cl_MI_fix16.h b/src/modinteger/cl_MI_fix16.h index 6bd2069..64fe7a9 100644 --- a/src/modinteger/cl_MI_fix16.h +++ b/src/modinteger/cl_MI_fix16.h @@ -66,10 +66,26 @@ class cl_heap_modint_ring_fix16 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_fix16 (const cl_I& m) - : cl_heap_modint_ring (m, &std_setops, &fix16_addops, &fix16_mulops) {} - // Virtual destructor. + cl_heap_modint_ring_fix16 (const cl_I& m); + // Destructor. ~cl_heap_modint_ring_fix16 () {} }; +static void cl_modint_ring_fix16_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_fix16*)pointer).~cl_heap_modint_ring_fix16(); +} + +cl_class cl_class_modint_ring_fix16 = { + cl_modint_ring_fix16_destructor, + cl_class_flags_modint_ring +}; + +// Constructor. +inline cl_heap_modint_ring_fix16::cl_heap_modint_ring_fix16(const cl_I& m) + : cl_heap_modint_ring (m, &std_setops, &fix16_addops, &fix16_mulops) +{ + type = &cl_class_modint_ring_fix16; +} + } // namespace cln diff --git a/src/modinteger/cl_MI_fix29.h b/src/modinteger/cl_MI_fix29.h index c72745a..3d7ef4f 100644 --- a/src/modinteger/cl_MI_fix29.h +++ b/src/modinteger/cl_MI_fix29.h @@ -73,10 +73,26 @@ class cl_heap_modint_ring_fix29 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_fix29 (const cl_I& m) - : cl_heap_modint_ring (m, &std_setops, &fix29_addops, &fix29_mulops) {} - // Virtual destructor. + cl_heap_modint_ring_fix29 (const cl_I& m); + // Destructor. ~cl_heap_modint_ring_fix29 () {} }; +static void cl_modint_ring_fix29_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_fix29*)pointer).~cl_heap_modint_ring_fix29(); +} + +cl_class cl_class_modint_ring_fix29 = { + cl_modint_ring_fix29_destructor, + cl_class_flags_modint_ring +}; + +// Constructor. +inline cl_heap_modint_ring_fix29::cl_heap_modint_ring_fix29(const cl_I& m) + : cl_heap_modint_ring (m, &std_setops, &fix29_addops, &fix29_mulops) +{ + type = &cl_class_modint_ring_fix29; +} + } // namespace cln diff --git a/src/modinteger/cl_MI_fix32.h b/src/modinteger/cl_MI_fix32.h index f3b49d4..8c1833f 100644 --- a/src/modinteger/cl_MI_fix32.h +++ b/src/modinteger/cl_MI_fix32.h @@ -75,10 +75,26 @@ class cl_heap_modint_ring_fix32 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_fix32 (const cl_I& m) - : cl_heap_modint_ring (m, &std_setops, &fix32_addops, &fix32_mulops) {} - // Virtual destructor. + cl_heap_modint_ring_fix32 (const cl_I& m); + // Destructor. ~cl_heap_modint_ring_fix32 () {} }; +static void cl_modint_ring_fix32_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_fix32*)pointer).~cl_heap_modint_ring_fix32(); +} + +cl_class cl_class_modint_ring_fix32 = { + cl_modint_ring_fix32_destructor, + cl_class_flags_modint_ring +}; + +// Constructor. +inline cl_heap_modint_ring_fix32::cl_heap_modint_ring_fix32(const cl_I& m) + : cl_heap_modint_ring (m, &std_setops, &fix32_addops, &fix32_mulops) +{ + type = &cl_class_modint_ring_fix32; +} + } // namespace cln diff --git a/src/modinteger/cl_MI_int32.h b/src/modinteger/cl_MI_int32.h index 6d542ca..8f073d6 100644 --- a/src/modinteger/cl_MI_int32.h +++ b/src/modinteger/cl_MI_int32.h @@ -74,10 +74,26 @@ class cl_heap_modint_ring_int32 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_int32 (const cl_I& m) - : cl_heap_modint_ring (m, &std_setops, &int32_addops, &int32_mulops) {} - // Virtual destructor. + cl_heap_modint_ring_int32 (const cl_I& m); + // Destructor. ~cl_heap_modint_ring_int32 () {} }; +static void cl_modint_ring_int32_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_int32*)pointer).~cl_heap_modint_ring_int32(); +} + +cl_class cl_class_modint_ring_int32 = { + cl_modint_ring_int32_destructor, + cl_class_flags_modint_ring +}; + +// Constructor. +inline cl_heap_modint_ring_int32::cl_heap_modint_ring_int32(const cl_I& m) + : cl_heap_modint_ring (m, &std_setops, &int32_addops, &int32_mulops) +{ + type = &cl_class_modint_ring_int32; +} + } // namespace cln diff --git a/src/modinteger/cl_MI_montgom.h b/src/modinteger/cl_MI_montgom.h index 1061a81..06222ee 100644 --- a/src/modinteger/cl_MI_montgom.h +++ b/src/modinteger/cl_MI_montgom.h @@ -70,7 +70,7 @@ class cl_heap_modint_ring_montgom : public cl_heap_modint_ring { public: // Constructor. cl_heap_modint_ring_montgom (const cl_I& M, uintL m, uintL n, const cl_I& V); - // Virtual destructor. + // Destructor. ~cl_heap_modint_ring_montgom () {} // Additional information. uintL m; // M = 2^m @@ -78,6 +78,16 @@ public: cl_I V; }; +static void cl_modint_ring_montgom_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_montgom*)pointer).~cl_heap_modint_ring_montgom(); +} + +cl_class cl_class_modint_ring_montgom = { + cl_modint_ring_montgom_destructor, + cl_class_flags_modint_ring +}; + // Assuming 0 <= x < 2^(2m), return V*x mod M. static inline const cl_I montgom_redc (cl_heap_modint_ring_montgom* R, const cl_I& x) { @@ -161,7 +171,9 @@ static cl_modint_mulops montgom_mulops = { inline cl_heap_modint_ring_montgom::cl_heap_modint_ring_montgom (const cl_I& M, uintL _m, uintL _n, const cl_I& _V) : cl_heap_modint_ring (M, &std_setops, &montgom_addops, &montgom_mulops), m (_m), n (_n), V (_V) -{} +{ + type = &cl_class_modint_ring_montgom; +} static cl_heap_modint_ring* try_make_modint_ring_montgom (const cl_I& M) { diff --git a/src/modinteger/cl_MI_pow2.h b/src/modinteger/cl_MI_pow2.h index 248968f..6746899 100644 --- a/src/modinteger/cl_MI_pow2.h +++ b/src/modinteger/cl_MI_pow2.h @@ -7,7 +7,7 @@ class cl_heap_modint_ring_pow2 : public cl_heap_modint_ring { public: // Constructor. cl_heap_modint_ring_pow2 (const cl_I& m, uintL m1); // m = 2^m1 - // Virtual destructor. + // Destructor. ~cl_heap_modint_ring_pow2 () {} // Additional information. uintL m1; @@ -137,8 +137,21 @@ static cl_modint_mulops pow2_mulops = { std_retract }; +static void cl_modint_ring_pow2_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_pow2*)pointer).~cl_heap_modint_ring_pow2(); +} + +cl_class cl_class_modint_ring_pow2 = { + cl_modint_ring_pow2_destructor, + cl_class_flags_modint_ring +}; + // Constructor. inline cl_heap_modint_ring_pow2::cl_heap_modint_ring_pow2 (const cl_I& m, uintL _m1) - : cl_heap_modint_ring (m, &std_setops, &pow2_addops, &pow2_mulops), m1 (_m1) {} + : cl_heap_modint_ring (m, &std_setops, &pow2_addops, &pow2_mulops), m1 (_m1) +{ + type = &cl_class_modint_ring_pow2; +} } // namespace cln diff --git a/src/modinteger/cl_MI_pow2m1.h b/src/modinteger/cl_MI_pow2m1.h index 4c073a2..2a36cfe 100644 --- a/src/modinteger/cl_MI_pow2m1.h +++ b/src/modinteger/cl_MI_pow2m1.h @@ -7,7 +7,7 @@ class cl_heap_modint_ring_pow2m1 : public cl_heap_modint_ring { public: // Constructor. cl_heap_modint_ring_pow2m1 (const cl_I& m, uintL m1); // m = 2^m1 - 1 - // Virtual destructor. + // Destructor. ~cl_heap_modint_ring_pow2m1 () {} // Additional information. uintL m1; @@ -78,8 +78,21 @@ static cl_modint_mulops pow2m1_mulops = { std_retract }; +static void cl_modint_ring_pow2m1_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_pow2m1*)pointer).~cl_heap_modint_ring_pow2m1(); +} + +cl_class cl_class_modint_ring_pow2m1 = { + cl_modint_ring_pow2m1_destructor, + cl_class_flags_modint_ring +}; + // Constructor. inline cl_heap_modint_ring_pow2m1::cl_heap_modint_ring_pow2m1 (const cl_I& m, uintL _m1) - : cl_heap_modint_ring (m, &std_setops, &pow2m1_addops, &pow2m1_mulops), m1 (_m1) {} + : cl_heap_modint_ring (m, &std_setops, &pow2m1_addops, &pow2m1_mulops), m1 (_m1) +{ + type = &cl_class_modint_ring_pow2m1; +} } // namespace cln diff --git a/src/modinteger/cl_MI_pow2p1.h b/src/modinteger/cl_MI_pow2p1.h index 0ee98a7..06477c8 100644 --- a/src/modinteger/cl_MI_pow2p1.h +++ b/src/modinteger/cl_MI_pow2p1.h @@ -7,7 +7,7 @@ class cl_heap_modint_ring_pow2p1 : public cl_heap_modint_ring { public: // Constructor. cl_heap_modint_ring_pow2p1 (const cl_I& m, uintL m1); // m = 2^m1 + 1 - // Virtual destructor. + // Destructor. ~cl_heap_modint_ring_pow2p1 () {} // Additional information. uintL m1; @@ -89,8 +89,21 @@ static cl_modint_mulops pow2p1_mulops = { std_retract }; +static void cl_modint_ring_pow2p1_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_pow2p1*)pointer).~cl_heap_modint_ring_pow2p1(); +} + +cl_class cl_class_modint_ring_pow2p1 = { + cl_modint_ring_pow2p1_destructor, + cl_class_flags_modint_ring +}; + // Constructor. inline cl_heap_modint_ring_pow2p1::cl_heap_modint_ring_pow2p1 (const cl_I& m, uintL _m1) - : cl_heap_modint_ring (m, &std_setops, &pow2p1_addops, &pow2p1_mulops), m1 (_m1) {} + : cl_heap_modint_ring (m, &std_setops, &pow2p1_addops, &pow2p1_mulops), m1 (_m1) +{ + type = &cl_class_modint_ring_pow2p1; +} } // namespace cln diff --git a/src/modinteger/cl_MI_std.h b/src/modinteger/cl_MI_std.h index e52494b..7507cc0 100644 --- a/src/modinteger/cl_MI_std.h +++ b/src/modinteger/cl_MI_std.h @@ -345,10 +345,26 @@ class cl_heap_modint_ring_std : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_std (const cl_I& m) - : cl_heap_modint_ring (m, &std_setops, &std_addops, &std_mulops) {} + cl_heap_modint_ring_std (const cl_I& m); // Virtual destructor. ~cl_heap_modint_ring_std () {} }; +static void cl_heap_modint_ring_std_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_std*)pointer).~cl_heap_modint_ring_std(); +} + +cl_class cl_class_modint_ring_std = { + cl_heap_modint_ring_std_destructor, + cl_class_flags_modint_ring +}; + +// Constructor. +inline cl_heap_modint_ring_std::cl_heap_modint_ring_std (const cl_I& m) + : cl_heap_modint_ring (m, &std_setops, &std_addops, &std_mulops) +{ + type = &cl_class_modint_ring_std; +} + } // namespace cln diff --git a/src/polynomial/elem/cl_UP.cc b/src/polynomial/elem/cl_UP.cc index a52fe8d..8da0200 100644 --- a/src/polynomial/elem/cl_UP.cc +++ b/src/polynomial/elem/cl_UP.cc @@ -38,14 +38,6 @@ cl_symbol cl_univpoly_varname_key = (cl_symbol)(cl_string)"variable name"; namespace cln { -cl_heap_univpoly_ring::cl_heap_univpoly_ring (const cl_ring& r, cl_univpoly_setops* setopv, cl_univpoly_addops* addopv, cl_univpoly_mulops* mulopv, cl_univpoly_modulops* modulopv, cl_univpoly_polyops* polyopv) - : setops (setopv), addops (addopv), mulops (mulopv), modulops (modulopv), polyops (polyopv), - _basering (r) -{ - refcount = 0; // will be incremented by the `cl_univpoly_ring' constructor - type = &cl_class_univpoly_ring; -} - static void cl_univpoly_ring_destructor (cl_heap* pointer) { (*(cl_heap_univpoly_ring*)pointer).~cl_heap_univpoly_ring(); @@ -56,9 +48,13 @@ cl_class cl_class_univpoly_ring = { 0 }; -// This tells the compiler to put the `cl_heap_univpoly_ring' vtable -// into this file. -void cl_heap_univpoly_ring::dummy () {} +cl_heap_univpoly_ring::cl_heap_univpoly_ring (const cl_ring& r, cl_univpoly_setops* setopv, cl_univpoly_addops* addopv, cl_univpoly_mulops* mulopv, cl_univpoly_modulops* modulopv, cl_univpoly_polyops* polyopv) + : setops (setopv), addops (addopv), mulops (mulopv), modulops (modulopv), polyops (polyopv), + _basering (r) +{ + refcount = 0; // will be incremented by the `cl_univpoly_ring' constructor + type = &cl_class_univpoly_ring; +} // Create a new univariate polynomial ring. @@ -67,7 +63,7 @@ cl_heap_univpoly_ring* cl_make_univpoly_ring (const cl_ring& r) { if (r.pointer_type()->flags & cl_class_flags_number_ring) return new cl_heap_num_univpoly_ring(r); - else if (r.pointer_type() == &cl_class_modint_ring) { + else if (r.pointer_type()->flags & cl_class_flags_modint_ring) { if (((cl_heap_modint_ring*)r.heappointer)->modulus == 2) return new cl_heap_gf2_univpoly_ring(r); else diff --git a/src/polynomial/elem/cl_UP_GF2.h b/src/polynomial/elem/cl_UP_GF2.h index 8ca6f21..a7d1551 100644 --- a/src/polynomial/elem/cl_UP_GF2.h +++ b/src/polynomial/elem/cl_UP_GF2.h @@ -1041,8 +1041,26 @@ class cl_heap_gf2_univpoly_ring : public cl_heap_univpoly_ring { SUBCLASS_cl_heap_univpoly_ring() public: // Constructor. - cl_heap_gf2_univpoly_ring (const cl_ring& r) - : cl_heap_univpoly_ring (r, &gf2_setops, &gf2_addops, &gf2_mulops, &gf2_modulops, &gf2_polyops) {} + cl_heap_gf2_univpoly_ring (const cl_ring& r); + // Destructor. + ~cl_heap_gf2_univpoly_ring () {} }; +static void cl_heap_gf2_univpoly_ring_destructor (cl_heap* pointer) +{ + (*(cl_heap_gf2_univpoly_ring*)pointer).~cl_heap_gf2_univpoly_ring(); +} + +cl_class cl_class_gf2_univpoly_ring = { + cl_heap_gf2_univpoly_ring_destructor, + 0 +}; + +// Constructor. +inline cl_heap_gf2_univpoly_ring::cl_heap_gf2_univpoly_ring (const cl_ring& r) + : cl_heap_univpoly_ring (r, &gf2_setops, &gf2_addops, &gf2_mulops, &gf2_modulops, &gf2_polyops) +{ + type = &cl_class_gf2_univpoly_ring; +} + } // namespace cln diff --git a/src/polynomial/elem/cl_UP_MI.h b/src/polynomial/elem/cl_UP_MI.h index 0b4d62f..664dc43 100644 --- a/src/polynomial/elem/cl_UP_MI.h +++ b/src/polynomial/elem/cl_UP_MI.h @@ -481,8 +481,26 @@ class cl_heap_modint_univpoly_ring : public cl_heap_univpoly_ring { SUBCLASS_cl_heap_univpoly_ring() public: // Constructor. - cl_heap_modint_univpoly_ring (const cl_ring& r) - : cl_heap_univpoly_ring (r, &modint_setops, &modint_addops, &modint_mulops, &modint_modulops, &modint_polyops) {} + cl_heap_modint_univpoly_ring (const cl_ring& r); + // Destructor. + ~cl_heap_modint_univpoly_ring () {} }; +static void cl_heap_modint_univpoly_ring_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_univpoly_ring*)pointer).~cl_heap_modint_univpoly_ring(); +} + +cl_class cl_class_modint_univpoly_ring = { + cl_heap_modint_univpoly_ring_destructor, + 0 +}; + +// Constructor. +inline cl_heap_modint_univpoly_ring::cl_heap_modint_univpoly_ring (const cl_ring& r) + : cl_heap_univpoly_ring (r, &modint_setops, &modint_addops, &modint_mulops, &modint_modulops, &modint_polyops) +{ + type = &cl_class_modint_univpoly_ring; +} + } // namespace cln diff --git a/src/polynomial/elem/cl_UP_gen.h b/src/polynomial/elem/cl_UP_gen.h index 1917f5b..ad9093b 100644 --- a/src/polynomial/elem/cl_UP_gen.h +++ b/src/polynomial/elem/cl_UP_gen.h @@ -460,8 +460,26 @@ class cl_heap_gen_univpoly_ring : public cl_heap_univpoly_ring { SUBCLASS_cl_heap_univpoly_ring() public: // Constructor. - cl_heap_gen_univpoly_ring (const cl_ring& r) - : cl_heap_univpoly_ring (r, &gen_setops, &gen_addops, &gen_mulops, &gen_modulops, &gen_polyops) {} + cl_heap_gen_univpoly_ring (const cl_ring& r); + // Destructor + ~cl_heap_gen_univpoly_ring () {} }; +static void cl_heap_gen_univpoly_ring_destructor (cl_heap* pointer) +{ + (*(cl_heap_gen_univpoly_ring*)pointer).~cl_heap_gen_univpoly_ring(); +} + +cl_class cl_class_gen_univpoly_ring = { + cl_heap_gen_univpoly_ring_destructor, + 0 +}; + +// Constructor. +inline cl_heap_gen_univpoly_ring::cl_heap_gen_univpoly_ring (const cl_ring& r) + : cl_heap_univpoly_ring (r, &gen_setops, &gen_addops, &gen_mulops, &gen_modulops, &gen_polyops) +{ + type = &cl_class_gen_univpoly_ring; +} + } // namespace cln diff --git a/src/polynomial/elem/cl_UP_number.h b/src/polynomial/elem/cl_UP_number.h index c5b5183..ea879b8 100644 --- a/src/polynomial/elem/cl_UP_number.h +++ b/src/polynomial/elem/cl_UP_number.h @@ -463,8 +463,26 @@ class cl_heap_num_univpoly_ring : public cl_heap_univpoly_ring { SUBCLASS_cl_heap_univpoly_ring() public: // Constructor. - cl_heap_num_univpoly_ring (const cl_ring& r) - : cl_heap_univpoly_ring (r, &num_setops, &num_addops, &num_mulops, &num_modulops, &num_polyops) {} + cl_heap_num_univpoly_ring (const cl_ring& r); + // Destructor. + ~cl_heap_num_univpoly_ring () {} }; +static void cl_heap_num_univpoly_ring_destructor (cl_heap* pointer) +{ + (*(cl_heap_num_univpoly_ring*)pointer).~cl_heap_num_univpoly_ring(); +} + +cl_class cl_class_num_univpoly_ring = { + cl_heap_num_univpoly_ring_destructor, + 0 +}; + +// Constructor. +inline cl_heap_num_univpoly_ring::cl_heap_num_univpoly_ring (const cl_ring& r) + : cl_heap_univpoly_ring (r, &num_setops, &num_addops, &num_mulops, &num_modulops, &num_polyops) +{ + type = &cl_class_num_univpoly_ring; +} + } // namespace cln