Release iteration resources
You can perform these deallocation tasks directly in the iterator function or you can declare a separate iterator-end function, which the iterator function calls when it receives the SET_END iterator-status value. Declare the iterator-end function to return the same data type as the main iterator function. However, the database server ignores the return value of this function; it does not put this return value in the active set.
mi_integer fibGen_end(fparam)
MI_FPARAM *fparam;
{
fibState *fibstate;
fibstate = (fibState *)mi_fp_funcstate(fparam);
mi_free(fibstate);
return (0); /* return value is ignored */
}
The fibGen_end() function uses the mi_fp_funcstate() function to obtain the user-state pointer from the MI_FPARAM structure. It then calls the mi_free() function to free the resources in the fibstate state structure, which the fibGen_init() function (see Figure 1) has allocated. The fibGen_end() function returns an mi_integer value (0) because the main iterator function, fibGen(), returns an active set of mi_integer values.