VgwStreamFreeFnc


Use the VgwStreamFreeFnc function to release resources, such as memory for data structures, acquired by your stream. The Verity engine calls your VgwStreamFreeFnc function when it receives a VdkTokenType_Eof token from the VgwStreamGetTokenFnc function associated with the stream.


Syntax

VdkError VgwStreamFreeFnc(
VgwAppStream   vgwStream)

Arguments

 


vgwstream

VgwAppStream   The stream handle, which was created in your driver’s VgwStreamNewFnc function.


Returns

This function must return one of the following error codes:

VdkSuccess for success

 

VdkError_* for a standard Verity Developer Kit API error as described in the Verity Developer’s Kit Programming Reference

 

VdkFail for a non-specific error

 


Discussion

In addition to the Verity engine calling your VgwStreamFreeFnc function when there are no more tokens in the stream, you can call VgwStreamFreeFnc also; for example, if your VgwStreamNewFnc function results in an error, you may need to free resources allocated in VgwStreamNewFnc before terminating.

If your VgwStreamFreeTokenFnc callback function did not free all tokens, you must free them in your VgwStreamFreeFnc function. For example, if you created all tokens in your gateway driver’s VgwStreamNewFnc function and used your driver’s VgwStreamGetTokenFnc function only to submit tokens to the Verity engine, you could release the tokens in your VgwStreamFreeFnc function.

You should free your stream data, referenced by vgwStream, after first releasing all other resources referenced by this stream handle.


Example

static VdkError
VDK_CALLBACK VgwStreamFree(VgwAppStream pStream)
{
if (!pStream)
return VdkSuccess;

/****************************************
* free the data created in VgwStreamNew
****************************************/

if (pStream->key)
free((void*)pStream->key);
if (pStream->field)
free((void*)pStream->field);

free(pStream);
return VdkSuccess;
}