#14304: New implementation of unramified p-adics using FLINT and templates
-------------------------------------+-------------------------------------
       Reporter:  roed               |        Owner:  roed
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.1
      Component:  padics             |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Julian Rueth,      |    Reviewers:  David Roe, Julian
  David Roe                          |  Rueth
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/roed/ticket/14304                |  60975a4eed6b9bc665219709e337f801eb2b264d
   Dependencies:  #12555, #12173     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by pbruin):

 Why not increment the `__allocated` counter after every successful
 allocation and use its value in `__dealloc__()` to decide which objects
 have to be deallocated?  E.g.
 {{{
 #!python
 def __cinit__(self, ...):
     sig_on()
     self.__allocated = 0
     fmpz_init(self.fmpz_ccmp); self.__allocated++
     fmpz_init(self.fmpz_cval); self.__allocated++
     ...
     fmpz_poly_init(self.poly_cconv); self.__allocated++
     fmpz_poly_init(self.poly_ctm); self.__allocated++
     ...
     sig_off()

 def __dealloc__(self, ...):
     if self.__allocated >= 1:
         fmpz_clear(self.fmpz_ccmp)
     if self.__allocated >= 2:
         fmpz_clear(self.fmpz_cval)
     ...
 }}}
 I hope I'm understanding the problem correctly; I'm just looking at the
 code and didn't follow the above discussion very closely.

--
Ticket URL: <http://trac.sagemath.org/ticket/14304#comment:40>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to