#14501: Fix memory allocation problems in data_structures_pyx.pxi
---------------------------------+------------------------------------------
       Reporter:  dcoudert       |         Owner:  joyner      
           Type:  defect         |        Status:  needs_review
       Priority:  major          |     Milestone:  sage-5.10   
      Component:  group theory   |    Resolution:              
       Keywords:                 |   Work issues:              
Report Upstream:  N/A            |     Reviewers:              
        Authors:  David Coudert  |     Merged in:              
   Dependencies:                 |      Stopgaps:              
---------------------------------+------------------------------------------

Comment (by dcoudert):

 > Why don't you just put a "calloc" where StabilizerChain is allocated
 then ?

 That's correct, and it allows for removing series of NULL assignments.
 Done.

 > > No, they are allocated using 2 distinct malloc. So the first one could
 succeed while the second one fails. In case the second fails, then it is
 set to NULL.
 >
 > That's the block of code you will see each time they are allocated
 > {{{
 >       SC.generators[i]   = <int *> sage_malloc( SC.array_size[i]*n *
 sizeof(int) )
 >       SC.gen_inverses[i] = <int *> sage_malloc( SC.array_size[i]*n *
 sizeof(int) )
 >       if SC.generators[i] is NULL or SC.gen_inverses[i] is NULL:
 >             SC_dealloc(SC)
 >             return NULL
 > }}}
 >
 > I swear that one cannot be NULL while the other is `:-P`

 Well, if {{{SC.generators[i] is NULL}}} then {{{SC.gen_inverses[i]}}}
 should also be NULL (unless something strange happens). However, the
 converse is false.

 For the {{{SC.generators is not NULL}}} test, you are right: if it is
 NULL, then it means it has never been assigned {{{int_ptrs}}} and so
 {{{SC.gen_inverses}}} is also NULL. In this case, the converse is also
 true. I have re-merged the tests.


 See updated patch.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14501#comment:11>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to