1 //------------------------------------------------------------------------------
2 // GrB_BinaryOp_free: free a binary operator
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 #include "GB.h"
11 
GrB_BinaryOp_free(GrB_BinaryOp * binaryop)12 GrB_Info GrB_BinaryOp_free          // free a user-created binary operator
13 (
14     GrB_BinaryOp *binaryop          // handle of binary operator to free
15 )
16 {
17 
18     if (binaryop != NULL)
19     {
20         // only free a dynamically-allocated operator
21         GrB_BinaryOp op = *binaryop ;
22         if (op != NULL)
23         {
24             size_t header_size = op->header_size ;
25             if (header_size > 0)
26             {
27                 op->magic = GB_FREED ;  // to help detect dangling pointers
28                 op->header_size = 0 ;
29                 GB_FREE (binaryop, header_size) ;
30             }
31         }
32     }
33 
34     return (GrB_SUCCESS) ;
35 }
36 
37