Initializing and Freeing Containers
LEADTOOLS accesses containers through the CONTAINERHANDLE structure. This structure provides a working area for the LEADTOOLS container functions. The container handle must be initialized before calling any of the container functions. This is done using the L_ContainerInit function. When the CONTAINERHANDLE structure is no longer needed, it should be freed using the L_ContainerFree function. Example code showing these calls is given below:
pCONTAINERHANDLE pLeadContainer ;
/* Initiate the container handle*/
L_ContainerInit ( &pLeadContainer ) ;
.
.
.
if (SUCCESS == L_ContainerIsValid ( pContainer ) ) /* check the validity of container handle */
{
/* Free the container handle */
L_ContainerFree ( pContainer ) ;
return SUCCESS ;
}
else
{
return FAILURE ;
}
A container handle is valid only after L_ContainerInit and L_ContainerCreate have been called. The validity of a container handle should be checked before calling any other container functions. This is done using L_ContainerIsValid. For more information on creating containers, refer to Creating a Container.