File: GB_bix_free.c

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (80 lines) | stat: -rw-r--r-- 2,271 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//------------------------------------------------------------------------------
// GB_bix_free: free A->(b,i,x) pending tuples, zombies; A->p, A->h unchanged
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// Since A->p and A->h are unchanged, the matrix is still valid (unless it was
// invalid on input).  nnz(A) would report zero, and so would GrB_Matrix_nvals.

#include "GB_Pending.h"

GB_PUBLIC
void GB_bix_free                // free A->b, A->i, and A->x of a matrix
(
    GrB_Matrix A                // matrix with content to free
)
{

    //--------------------------------------------------------------------------
    // check inputs
    //--------------------------------------------------------------------------

    if (A == NULL)
    { 
        // nothing to do
        return ;
    }

    //--------------------------------------------------------------------------
    // free all but A->p and A->h
    //--------------------------------------------------------------------------

    // zombies and pending tuples are about to be deleted
    ASSERT (GB_ZOMBIES_OK (A)) ;
    ASSERT (GB_PENDING_OK (A)) ;
    ASSERT (GB_JUMBLED_OK (A)) ;

    // free A->b unless it is shallow
    if (!A->b_shallow)
    { 
        GB_FREE (&(A->b), A->b_size) ;
    }
    A->b = NULL ;
    A->b_size = 0 ;
    A->b_shallow = false ;

    // free A->i unless it is shallow
    if (!A->i_shallow)
    { 
        GB_FREE (&(A->i), A->i_size) ;
    }
    A->i = NULL ;
    A->i_size = 0 ;
    A->i_shallow = false ;

    // free A->x unless it is shallow
    if (!A->x_shallow)
    { 
        GB_FREE (&(A->x), A->x_size) ;
    }
    A->x = NULL ;               // GB_nnz_max (A) will report zero
    A->x_size = 0 ;
    A->x_shallow = false ;
    A->iso = false ;            // OK: all components are freed; no longer iso

    A->nvals = 0 ;

    // no zombies remain
    A->nzombies = 0 ;

    // an empty matrix is not jumbled
    A->jumbled = false ;

    // free the list of pending tuples
    GB_Pending_free (&(A->Pending)) ;
}