The type_free_inst Function

The stubs call the type_free_inst function to free memory associated with the presented type. The function is defined as:

void __RPC_USER <type>_free_inst(<type> __RPC_FAR *)
 

The parameter points to the presented type instance. This object should not be freed. For a discussion on when to call the function, see the transmit_as Attribute.

In the following example, the double-linked list is freed by walking the list to its end, then backing up and freeing each element of the list.

void __RPC_USER DOUBLE_LINK_TYPE_free_inst(
     DOUBLE_LINK_TYPE __RPC_FAR * pList)
{
    while (pList->pNext != NULL)  // go to end of the list
        pList = pList->pNext;

    pList = pList->pPrevious;
    while (pList != NULL) {  // back through the list
        midl_user_free(pList->pNext);
        pList = pList->pPrevious;
    }
}