1 #include "BSprivate.h"
2 
3 /*@ BSfree_spmat - Free a sparse matrix (original format)
4 
5     Input Parameters:
6 .   A - The sparse matrix
7 
8     Returns:
9     void
10 
11  @*/
BSfree_spmat(BSspmat * A)12 void BSfree_spmat(BSspmat *A)
13 {
14 	int	i;
15 
16 	for (i=0;i<A->num_rows;i++) {
17 		MY_FREE(A->rows[i]->col);
18 		if (A->rows[i]->nz != NULL) MY_FREE(A->rows[i]->nz);
19 		MY_FREE(A->rows[i]);
20 	}
21 	if (A->map != NULL) {
22 		if (A->map->free_l2g != NULL) {
23 			(*A->map->free_l2g)(A->map->vlocal2global); CHKERR(0);
24 		}
25 		if (A->map->free_g2l != NULL) {
26 			(*A->map->free_g2l)(A->map->vglobal2local); CHKERR(0);
27 		}
28 		if (A->map->free_g2p != NULL) {
29 			(*A->map->free_g2p)(A->map->vglobal2proc); CHKERR(0);
30 		}
31 		MY_FREE(A->map);
32 	}
33 	MY_FREE(A->rows);
34 	MY_FREE(A);
35 }
36