CustomProcess_Cleanup Function

Applies To: Implementing a custom process

Cleans up variables and destroys the client handle, freeing up any allocated memory.

[C++]

  CustomProcess_API BOOL __stdcall CustomProcess_Cleanup(void* clientHandle);

Arguments

[in] clientHandle

Unique ID used to identify the caller.

The client handle is not supposed to be used after the cleanup function. This is generally the last function called for one particular client handle.

Return Value

A Boolean value signifying if the client handle was successfully cleaned up.

Reporting errors and warnings: Any errors can be obtained by calling the GetLastError function which will give out the error message for the last error in the dll.

Example

The following example represents a partial C++ implementation of this function:

[C++]

typedef struct

{

    AreaOfInterest* myAoi;

    NVM* myProcessProps;

    unsigned long myNumProps;

    CustomRasterInfo* myOutputRasterInfo;

    unsigned long bufferSize;

    char errorString[2048];

    unsigned char* myOutputBuffer;

    void* myCallbackObject;

    NVM* myProcessMetadata;

    unsigned long myNumMetadata;

    tGetRowfn myGetRowfn;

    tGetPropertyfn myGetPropertyfn;

    tCreateAuxRasterfn myCreateAuxRasterfn;

    tGetAuxRowfn myGetAuxRowfn;

}ClientHandle;

 

CustomProcess_API BOOL __stdcall CustomProcess_Cleanup(void* clientHandle)

{

    ClientHandle* myClientHandle = (ClientHandle*)clientHandle;

    unsigned long i = 0;

 

    myClientHandle->myAoi = 0;

    myClientHandle->myProcessProps = 0;

    myClientHandle->myOutputRasterInfo = 0;

    free(myClientHandle->myOutputBuffer);

    myClientHandle->myCallbackObject = 0;

    for (;i < myClientHandle->myNumMetadata; ++i)

    {

        free(myClientHandle->myProcessMetadata[i].Name);

        free(myClientHandle->myProcessMetadata[i].Value);

    }

    free(myClientHandle->myProcessMetadata);

    myClientHandle->myGetRowfn = 0;

    myClientHandle->myGetPropertyfn = 0;

    myClientHandle->myCreateAuxRasterfn = 0;

    myClientHandle->myGetAuxRowfn = 0;

    free(myClientHandle);

    return TRUE;

}

For a detailed example on how to implement this function, see Sample custom process.

Related Topics

See also: CustomProcess_Create, CustomProcess_SetWindow, CustomProcess_Initialize, CustomProcess_GetRow, CustomProcess_GetMetadata, CustomProcess_GetLastError, CustomProcess_SetCallbackFunctions, CustomProcess_SetAreaOfInterest, CustomProcessUI_Init, CustomProcessUI_ShowModalDialog, CustomProcessUI_GetUpdatedXML, CustomProcessUI_GetStatus, CustomProcessUI_GetProperty, CustomProcessUI_SetProperty