util.c File Reference

Detailed Description

Utility functions.

Author:
Ben Bornstein

Ths file implements a small number of utility functions that may be useful inside and outside of libSBML.

Include dependency graph for util.c:

Functions

void util_free (void *element)
 Function for freeing memory allocated by libSBML functions.
void util_freeArray (void **objects, int length)
 Function for freeing memory allocated by libSBML functions.
int util_isInf (double d)
 Function for testing whether a given value represents negative infinity.
int util_isNegZero (double d)
 Function for testing whether a given value represents negative zero.
double util_NaN (void)
 Returns a representation of NaN.
double util_NegInf (void)
 Returns a representation of the IEEE-754 "Negative Infinity" value.
double util_NegZero (void)
 Returns a representation of the IEEE-754 "Negative Zero" value.
double util_PosInf (void)
 Returns a representation of the IEEE-754 "Positive Infinity" value.

Function Documentation

void util_free ( void *  element)

Function for freeing memory allocated by libSBML functions.

Parameters:
elementpointer to the object to be freed. It must be data that was originally allocated by a libSBML function.

This function was introduced to deal with a specific memory issue arising on Windows OS when using libSBML compiled against a static MSVC runtime library. In this situation, it was not possible to use the standard free() function when freeing memory that was actually allocated within the libSBML function call. The following is an example of where the free function fails and needs to be replaced with util_free().

    char * formula = SBML_formulaToString(astNode);
    free(formula);
Note:
This function is only necessary when using a version of libSBML compiled and linked against a static MSVC runtime library.
void util_freeArray ( void **  objects,
int  length 
)

Function for freeing memory allocated by libSBML functions.

Parameters:
objectspointer to the array to be freed. It must be data that was originally allocated by a libSBML function.
lengthnumber of elements in the array to be freed.

This function was introduced to deal with a specific memory issue arising on Windows OS when using libSBML compiled against a static MSVC runtime library. In this situation, it was not possible to use the standard free() function when freeing memory that was actually allocated within the libSBML function call. The following is an example of where the free function fails and needs to be replaced with util_freeArray().

    int length;
    SBMLNamespaces_t** supported = SBMLNamespaces_getSupportedNamespaces(&length);
    free(supported);
Note:
This function is only necessary when using a version of libSBML compiled and linked against a static MSVC runtime library.
int util_isInf ( double  d)

Function for testing whether a given value represents negative infinity.

Parameters:
dthe floating-point value to test
Returns:
-1 (for false) if d represents negative infinity, 1 if d represents positive infinity, and 0 otherwise.
int util_isNegZero ( double  d)

Function for testing whether a given value represents negative zero.

Parameters:
dthe floating-point value to test
Returns:
nonzero (for true) if d is an IEEE-754 negative zero, zero (for false) otherwise.
double util_NaN ( void  )

Returns a representation of NaN.

Returns:
a (quiet) NaN.
double util_NegInf ( void  )

Returns a representation of the IEEE-754 "Negative Infinity" value.

Returns:
IEEE-754 Negative Infinity.
double util_NegZero ( void  )

Returns a representation of the IEEE-754 "Negative Zero" value.

Returns:
IEEE-754 Negative Zero.
double util_PosInf ( void  )

Returns a representation of the IEEE-754 "Positive Infinity" value.

Returns:
IEEE-754 Positive Infinity
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines