Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Rename sage_malloc -> sig_malloc and friends
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Mar 15, 2016
1 parent dce67fc commit 4bb8337
Show file tree
Hide file tree
Showing 123 changed files with 1,397 additions and 1,397 deletions.
4 changes: 2 additions & 2 deletions src/ext/valgrind/sage-additional.supp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
mpfr_init2
Memcheck:Leak
fun:malloc
fun:sage_malloc
fun:sig_malloc
fun:sage_mpir_malloc
fun:mpfr_init2
}
Expand All @@ -379,7 +379,7 @@
mpir_realloc
Memcheck:Leak
fun:realloc
fun:sage_realloc
fun:sig_realloc
fun:sage_mpir_realloc
fun:__gmpz_realloc
fun:__gmpz_add_ui
Expand Down
390 changes: 195 additions & 195 deletions src/sage/coding/binary_code.pyx

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/sage/coding/codecan/codecan.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
for i in range(self._hyp_part.degree):
bitset_free(self._hyp2points[i])
sage_free(self._hyp2points)
sage_free(self._points2hyp)
sig_free(self._hyp2points)
sig_free(self._points2hyp)
PS_dealloc(self._hyp_part)
sage_free(self._hyp_refine_vals_scratch)
sig_free(self._hyp_refine_vals_scratch)
def __repr__(self):
"""
Expand Down Expand Up @@ -781,12 +781,12 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
if s >= 0:
self._hyp_part.levels[s] = 0
self._hyp2points = < bitset_t *> sage_malloc(self._hyp_part.degree * sizeof(bitset_t))
self._hyp2points = < bitset_t *> sig_malloc(self._hyp_part.degree * sizeof(bitset_t))
if self._hyp2points is NULL:
raise MemoryError('allocating PartitionRefinementLinearCode')
self._points2hyp = < bitset_t *> sage_malloc(self._n * sizeof(bitset_t))
self._points2hyp = < bitset_t *> sig_malloc(self._n * sizeof(bitset_t))
if self._hyp2points is NULL:
sage_free(self._hyp2points)
sig_free(self._hyp2points)
raise MemoryError('allocating PartitionRefinementLinearCode')
for i in range(self._n):
Expand All @@ -800,7 +800,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
bitset_add(self._hyp2points[i], j)
bitset_add(self._points2hyp[j], i)
self._hyp_refine_vals_scratch = <long *> sage_malloc(
self._hyp_refine_vals_scratch = <long *> sig_malloc(
self._hyp_part.degree * sizeof(long))
if self._hyp_refine_vals_scratch is NULL:
raise MemoryError('allocating PartitionRefinementLinearCode')
Expand Down Expand Up @@ -972,7 +972,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
cdef bitset_t *nonsingletons
cdef bitset_t scratch
bitset_init(scratch, self._hyp_part.degree)
nonsingletons = < bitset_t *> sage_malloc(0)
nonsingletons = < bitset_t *> sig_malloc(0)
cdef int nr_cells = PS_all_new_cells(self._hyp_part, & nonsingletons)
for i in range(self._n):
Expand All @@ -984,7 +984,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
for j in range(nr_cells):
bitset_free(nonsingletons[j])
sage_free(nonsingletons)
sig_free(nonsingletons)
bitset_free(scratch)
# provide some space to store the result (if not already exists)
Expand Down Expand Up @@ -1017,7 +1017,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
cdef bitset_t *nonsingletons
cdef bitset_t scratch
bitset_init(scratch, self._part.degree)
nonsingletons = < bitset_t *> sage_malloc(0)
nonsingletons = < bitset_t *> sig_malloc(0)
cdef int nr_cells = PS_all_new_cells(self._part, & nonsingletons)
for i in range(self._hyp_part.degree):
Expand All @@ -1029,7 +1029,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
for j in range(nr_cells):
bitset_free(nonsingletons[j])
sage_free(nonsingletons)
sig_free(nonsingletons)
bitset_free(scratch)
# provide some space to store the result (if not already exists)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/combinat_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k):
mpz_init(t)
mpz_init(u)
max_bc = (k+1)//2
bc = <mpz_t*> sage_malloc((max_bc+1) * sizeof(mpz_t))
bc = <mpz_t*> sig_malloc((max_bc+1) * sizeof(mpz_t))
mpz_init_set_ui(bc[0], 1)
for j in range(1, max_bc+1):
mpz_init_set(bc[j], bc[j-1])
Expand All @@ -115,7 +115,7 @@ cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k):
mpz_mul_2exp(u, u, n)
for j in range(max_bc+1): # careful: 0 ... max_bc
mpz_clear(bc[j])
sage_free(bc)
sig_free(bc)
mpz_fac_ui(t, k)
mpz_tdiv_q(s, s, t)
mpz_clear(t)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/degree_sequences.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class DegreeSequences:
Freeing the memory
"""
if seq != NULL:
sage_free(seq)
sig_free(seq)

cdef init(int n):
"""
Expand All @@ -399,7 +399,7 @@ cdef init(int n):
return [[0]]

sig_on()
seq = <unsigned char *> sage_malloc((n+1)*sizeof(unsigned char))
seq = <unsigned char *> sig_malloc((n+1)*sizeof(unsigned char))
memset(seq,0,(n+1)*sizeof(unsigned char))
sig_off()

Expand All @@ -409,7 +409,7 @@ cdef init(int n):
N = n
sequences = []
enum(1,0)
sage_free(seq)
sig_free(seq)
return sequences

cdef inline add_seq():
Expand Down
82 changes: 41 additions & 41 deletions src/sage/combinat/designs/designs_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def is_orthogonal_array(OA, int k, int n, int t=2, verbose=False, terminology="O
cdef int i,j,l

# A copy of OA
cdef unsigned short * OAc = <unsigned short *> sage_malloc(k*n2*sizeof(unsigned short))
cdef unsigned short * OAc = <unsigned short *> sig_malloc(k*n2*sizeof(unsigned short))

cdef unsigned short * C1
cdef unsigned short * C2
Expand All @@ -121,7 +121,7 @@ def is_orthogonal_array(OA, int k, int n, int t=2, verbose=False, terminology="O
if verbose:
print {"OA" : "{} is not in the interval [0..{}]".format(x,n-1),
"MOLS" : "Entry {} was expected to be in the interval [0..{}]".format(x,n-1)}[terminology]
sage_free(OAc)
sig_free(OAc)
return False
OAc[j*n2+i] = x

Expand All @@ -138,14 +138,14 @@ def is_orthogonal_array(OA, int k, int n, int t=2, verbose=False, terminology="O
bitset_add(seen,n*C1[l]+C2[l])

if bitset_len(seen) != n2: # Have we seen all pairs ?
sage_free(OAc)
sig_free(OAc)
bitset_free(seen)
if verbose:
print {"OA" : "Columns {} and {} are not orthogonal".format(i,j),
"MOLS" : "Squares {} and {} are not orthogonal".format(i,j)}[terminology]
return False

sage_free(OAc)
sig_free(OAc)
bitset_free(seen)
return True

Expand Down Expand Up @@ -267,7 +267,7 @@ def is_group_divisible_design(groups,blocks,v,G=None,K=None,lambd=1,verbose=Fals
print "{} does not belong to [0,...,{}]".format(x,n-1)
return False

cdef unsigned short * matrix = <unsigned short *> sage_calloc(n*n,sizeof(unsigned short))
cdef unsigned short * matrix = <unsigned short *> sig_calloc(n*n,sizeof(unsigned short))
if matrix is NULL:
raise MemoryError

Expand Down Expand Up @@ -298,7 +298,7 @@ def is_group_divisible_design(groups,blocks,v,G=None,K=None,lambd=1,verbose=Fals
if not len(g) in G:
if verbose:
print "a group has size {} while G={}".format(len(g),list(G))
sage_free(matrix)
sig_free(matrix)
return False

# Checks that two points of the same group were never covered
Expand All @@ -311,7 +311,7 @@ def is_group_divisible_design(groups,blocks,v,G=None,K=None,lambd=1,verbose=Fals
if matrix[ii*n+jj] != 0:
if verbose:
print "the pair ({},{}) belongs to a group but appears in some block".format(ii,jj)
sage_free(matrix)
sig_free(matrix)
return False

# We fill the entries with what is expected by the next loop
Expand All @@ -324,10 +324,10 @@ def is_group_divisible_design(groups,blocks,v,G=None,K=None,lambd=1,verbose=Fals
if matrix[i*n+j] != l:
if verbose:
print "the pair ({},{}) has been seen {} times but lambda={}".format(i,j,matrix[i*n+j],l)
sage_free(matrix)
sig_free(matrix)
return False

sage_free(matrix)
sig_free(matrix)

return True if not guess_groups else (True, groups)

Expand Down Expand Up @@ -627,15 +627,15 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
cdef dict group_to_int = {v:i for i,v in enumerate(int_to_group)}

# Allocations
cdef int ** x_minus_y = <int **> sage_malloc((n+1)*sizeof(int *))
cdef int * x_minus_y_data = <int *> sage_malloc((n+1)*(n+1)*sizeof(int))
cdef int * M_c = <int *> sage_malloc(k*M_nrows*sizeof(int))
cdef int * G_seen = <int *> sage_malloc((n+1)*sizeof(int))
cdef int ** x_minus_y = <int **> sig_malloc((n+1)*sizeof(int *))
cdef int * x_minus_y_data = <int *> sig_malloc((n+1)*(n+1)*sizeof(int))
cdef int * M_c = <int *> sig_malloc(k*M_nrows*sizeof(int))
cdef int * G_seen = <int *> sig_malloc((n+1)*sizeof(int))
if (x_minus_y == NULL or x_minus_y_data == NULL or M_c == NULL or G_seen == NULL):
sage_free(x_minus_y)
sage_free(x_minus_y_data)
sage_free(G_seen)
sage_free(M_c)
sig_free(x_minus_y)
sig_free(x_minus_y_data)
sig_free(G_seen)
sig_free(M_c)
raise MemoryError

# The "x-y" table. If g_i, g_j \in G, then x_minus_y[i][j] is equal to
Expand Down Expand Up @@ -674,10 +674,10 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
if bit:
if verbose:
print "Row {} contains more than one empty entry".format(i)
sage_free(x_minus_y_data)
sage_free(x_minus_y)
sage_free(G_seen)
sage_free(M_c)
sig_free(x_minus_y_data)
sig_free(x_minus_y)
sig_free(G_seen)
sig_free(M_c)
return False
bit = True

Expand All @@ -691,10 +691,10 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
if verbose:
print ("Column {} contains {} empty entries instead of the expected "
"lambda.u={}.{}={}".format(j,ii,lmbda,u,lmbda*u))
sage_free(x_minus_y_data)
sage_free(x_minus_y)
sage_free(G_seen)
sage_free(M_c)
sig_free(x_minus_y_data)
sig_free(x_minus_y)
sig_free(G_seen)
sig_free(M_c)
return False

# We are now ready to test every pair of columns
Expand All @@ -708,10 +708,10 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
if verbose:
print ("Columns {} and {} generate 0 exactly {} times "
"instead of the expected mu(={})".format(i,j,G_seen[0],mu))
sage_free(x_minus_y_data)
sage_free(x_minus_y)
sage_free(G_seen)
sage_free(M_c)
sig_free(x_minus_y_data)
sig_free(x_minus_y)
sig_free(G_seen)
sig_free(M_c)
return False

for ii in range(1,n): # bad number of g_ii\in G
Expand All @@ -720,23 +720,23 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
print ("Columns {} and {} do not generate all elements of G "
"exactly lambda(={}) times. The element {} appeared {} "
"times as a difference.".format(i,j,lmbda,int_to_group[ii],G_seen[ii]))
sage_free(x_minus_y_data)
sage_free(x_minus_y)
sage_free(G_seen)
sage_free(M_c)
sig_free(x_minus_y_data)
sig_free(x_minus_y)
sig_free(G_seen)
sig_free(M_c)
return False

sage_free(x_minus_y_data)
sage_free(x_minus_y)
sage_free(G_seen)
sage_free(M_c)
sig_free(x_minus_y_data)
sig_free(x_minus_y)
sig_free(G_seen)
sig_free(M_c)
return True

# Cached information for OA constructions (see .pxd file for more info)

_OA_cache = <cache_entry *> sage_malloc(2*sizeof(cache_entry))
_OA_cache = <cache_entry *> sig_malloc(2*sizeof(cache_entry))
if (_OA_cache == NULL):
sage_free(_OA_cache)
sig_free(_OA_cache)
raise MemoryError
_OA_cache[0].max_true = -1
_OA_cache[1].max_true = -1
Expand All @@ -756,9 +756,9 @@ cpdef _OA_cache_set(int k,int n,truth_value):
cdef int i
if _OA_cache_size <= n:
new_cache_size = n+100
_OA_cache = <cache_entry *> sage_realloc(_OA_cache,new_cache_size*sizeof(cache_entry))
_OA_cache = <cache_entry *> sig_realloc(_OA_cache,new_cache_size*sizeof(cache_entry))
if _OA_cache == NULL:
sage_free(_OA_cache)
sig_free(_OA_cache)
raise MemoryError

for i in range(_OA_cache_size,new_cache_size):
Expand Down
16 changes: 8 additions & 8 deletions src/sage/combinat/designs/evenly_distributed_sets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ cdef class EvenlyDistributedSetsBacktracker:

def __dealloc__(self):
if self.diff != NULL:
sage_free(self.diff[0])
sage_free(self.diff)
sig_free(self.diff[0])
sig_free(self.diff)
if self.ratio != NULL:
sage_free(self.ratio[0])
sage_free(self.ratio)
sage_free(self.min_orb)
sage_free(self.B)
sage_free(self.cosets)
sage_free(self.t)
sig_free(self.ratio[0])
sig_free(self.ratio)
sig_free(self.min_orb)
sig_free(self.B)
sig_free(self.cosets)
sig_free(self.t)

def __init__(self, K, k, up_to_isomorphism=True, check=False):
r"""
Expand Down
Loading

0 comments on commit 4bb8337

Please sign in to comment.