Line data Source code
1 : //------------------------------------------------------------------------------ 2 : // LAGraph_Delete: deletes a graph and all its contents 3 : //------------------------------------------------------------------------------ 4 : 5 : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved. 6 : // SPDX-License-Identifier: BSD-2-Clause 7 : // 8 : // For additional details (including references to third party source code and 9 : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See 10 : // Contributors.txt for a full list of contributors. Created, in part, with 11 : // funding and support from the U.S. Government (see Acknowledgments.txt file). 12 : // DM22-0790 13 : 14 : // Contributed by Timothy A. Davis, Texas A&M University 15 : 16 : //------------------------------------------------------------------------------ 17 : 18 : #include "LG_internal.h" 19 : 20 1136 : int LAGraph_Delete 21 : ( 22 : // input/output: 23 : LAGraph_Graph *G, // the graph to delete; G set to NULL on output. 24 : // All internal GrB_Matrix and GrB_Vector objects are 25 : // freed, including G->A. To keep G->A while deleting 26 : // the graph G, use: 27 : // { A = G->A ; G->A = NULL ; LAGraph_Delete (&G, msg);} 28 : char *msg 29 : ) 30 : { 31 : 32 : //-------------------------------------------------------------------------- 33 : // check inputs 34 : //-------------------------------------------------------------------------- 35 : 36 1136 : LG_CLEAR_MSG ; 37 1136 : if (G == NULL || (*G) == NULL) 38 : { 39 : // success: nothing to do 40 3 : return (GrB_SUCCESS) ; 41 : } 42 : 43 : //-------------------------------------------------------------------------- 44 : // free the cached contents of the graph 45 : //-------------------------------------------------------------------------- 46 : 47 1133 : LG_TRY (LAGraph_DeleteCached (*G, msg)) ; 48 : 49 : //-------------------------------------------------------------------------- 50 : // delete the primary contents of the graph, and the graph itself 51 : //-------------------------------------------------------------------------- 52 : 53 1133 : GRB_TRY (GrB_free (&((*G)->A))) ; 54 1133 : LAGraph_Free ((void **) G, NULL) ; 55 1133 : return (GrB_SUCCESS) ; 56 : }