1 //------------------------------------------------------------------------------
2 // gb_mxfree: mxFree wrapper
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: GPL-3.0-or-later
7 
8 //------------------------------------------------------------------------------
9 
10 // Usage:
11 
12 //  void *p = mxMalloc ( ... ) ;
13 //  gb_mxfree (&p) ;                // frees p and sets p to NULL
14 
15 #include "gb_matlab.h"
16 
gb_mxfree(void ** p_handle)17 void gb_mxfree              // mxFree wrapper
18 (
19     void **p_handle         // handle to pointer to be freed
20 )
21 {
22 
23     if (p_handle != NULL)
24     {
25         if (*p_handle != NULL)
26         {
27             mxFree (*p_handle) ;
28         }
29         (*p_handle) = NULL ;
30     }
31 }
32 
33