//------------------------------------------------------------------------------
// GxB_initialized: determine if GraphBLAS has been initialized
//------------------------------------------------------------------------------

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

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

// GxB_initialized returns true if GrB_init has been called, or false if it
// not been.  When GrB_finalized is called, this routine will return false,
// thus indicating that GrB_init can be called again.

// This method can be called at any time: before GrB_init, after GrB_init but
// before GrB_finalized, or after GrB_finalize.

#include "GB.h"
#include "init/GB_init.h"

GrB_Info GxB_initialized    // determine if GraphBLAS is initialized
(
    int *flag               // returns true if GrB_init or GxB_init has been
                            // called (and the corresponding GrB_finalize
                            // has not), false otherwise
)
{ 

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

    if (flag == NULL)
    { 
        return (GrB_NULL_POINTER) ;
    }

    //--------------------------------------------------------------------------
    // check if GraphBLAS has been initialized
    //--------------------------------------------------------------------------

    (*flag) = GB_Global_GrB_init_called_get ( ) ;
    return (GrB_SUCCESS) ;
}

