1 //------------------------------------------------------------------------------
2 // GB_bix_free: free A->(b,i,x) pending tuples, zombies; A->p, A->h unchanged
3 //------------------------------------------------------------------------------
4
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7
8 //------------------------------------------------------------------------------
9
10 // Since A->p and A->h are unchanged, the matrix is still valid (unless it was
11 // invalid on input). nnz(A) would report zero, and so would GrB_Matrix_nvals.
12
13 #include "GB_Pending.h"
14
15 GB_PUBLIC // accessed by the MATLAB tests in GraphBLAS/Test only
GB_bix_free(GrB_Matrix A)16 void GB_bix_free // free A->b, A->i, and A->x of a matrix
17 (
18 GrB_Matrix A // matrix with content to free
19 )
20 {
21
22 //--------------------------------------------------------------------------
23 // check inputs
24 //--------------------------------------------------------------------------
25
26 if (A == NULL)
27 {
28 // nothing to do
29 return ;
30 }
31
32 //--------------------------------------------------------------------------
33 // free all but A->p and A->h
34 //--------------------------------------------------------------------------
35
36 // zombies and pending tuples are about to be deleted
37 ASSERT (GB_ZOMBIES_OK (A)) ;
38 ASSERT (GB_PENDING_OK (A)) ;
39 ASSERT (GB_JUMBLED_OK (A)) ;
40
41 // free A->b unless it is shallow
42 if (!A->b_shallow)
43 {
44 GB_FREE (&(A->b), A->b_size) ;
45 }
46 A->b = NULL ;
47 A->b_size = 0 ;
48 A->b_shallow = false ;
49
50 // free A->i unless it is shallow
51 if (!A->i_shallow)
52 {
53 GB_FREE (&(A->i), A->i_size) ;
54 }
55 A->i = NULL ;
56 A->i_size = 0 ;
57 A->i_shallow = false ;
58
59 // free A->x unless it is shallow
60 if (!A->x_shallow)
61 {
62 GB_FREE (&(A->x), A->x_size) ;
63 }
64 A->x = NULL ;
65 A->x_size = 0 ;
66 A->x_shallow = false ;
67
68 A->nzmax = 0 ;
69 A->nvals = 0 ;
70
71 // no zombies remain
72 A->nzombies = 0 ;
73
74 // an empty matrix is not jumbled
75 A->jumbled = false ;
76
77 // free the list of pending tuples
78 GB_Pending_free (&(A->Pending)) ;
79 }
80
81