Ticket #12905: trac_12905.patch

File trac_12905.patch, 1.5 KB (added by ncohen, 8 years ago)
  • sage/graphs/cliquer.pxd

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1336122074 -7200
    # Node ID bc0193e33aa070aa7b85e51d0e9a1eecee20d2a9
    # Parent  f58cebb10eeeb8e1fcaed9f36f953f475c338f95
    Fixing memory leaks in Cliquer
    
    diff --git a/sage/graphs/cliquer.pxd b/sage/graphs/cliquer.pxd
    a b  
    1919     cdef int sage_clique_max(graph_t *g, int ** list)
    2020     cdef int sage_all_clique_max(graph_t *g, int ** list)
    2121     cdef int sage_clique_number(graph_t *g)
    22      cdef void parse_input(char *str,graph_t *g)
    2322
    2423cdef extern from "cliquer/graph.h":
    2524     cdef graph_t * graph_new(int n)
    2625     cdef void graph_print(graph_t *g)
     26     cdef void parse_input(char *str,graph_t *g)
     27     cdef void graph_free(graph_t *g)
    2728
  • sage/graphs/cliquer.pyx

    diff --git a/sage/graphs/cliquer.pyx b/sage/graphs/cliquer.pyx
    a b  
    3434
    3535
    3636include "../ext/interrupt.pxi"
    37 
     37include '../ext/stdsage.pxi'
    3838
    3939def max_clique(graph):
    4040    """
     
    8282    cdef int i
    8383    for i in range(size):
    8484        b.append(list[i])
     85
     86    sage_free(list)
     87    graph_free(g)
    8588    return list_composition(b,d_inv)
    8689
    8790
     
    152155        else:
    153156            b.append(list_composition(c,d_inv))
    154157            c=[]
     158
     159    sage_free(list)
     160    graph_free(g)
     161
    155162    return sorted(b)
    156163
    157164
     
    189196    cdef int c
    190197    sig_on()
    191198    c = sage_clique_number(g)
     199    graph_free(g)
    192200    sig_off()
    193201    return c
    194202