Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

void sah_Descriptor_Chain_Destroy ( const sah_Mem_Util mu,
sah_Head_Desc **  desc_head 
)

Destroy a descriptor chain and free memory of associated links.

Releases the memory allocated by the Security Function library for descriptors, links and any internally allocated memory referenced in the given chain. Note that memory allocated by user applications is not released.

Postcondition:
The desc_head pointer will be set to NULL to prevent further use.
Parameters:
mu Memory functions
desc_head Pointer to head of descriptor chain to be freed
Returns:
none

Definition at line 222 of file sf_util.c.

References sah_Mem_Util::mu_free_desc, sah_Mem_Util::mu_free_head_desc, sah_Mem_Util::mu_ref, sah_Desc::next, sah_Desc::ptr1, sah_Desc::ptr2, and sah_Destroy_Link().

Referenced by sah_Postprocess_Results().

{
    sah_Desc *desc_ptr = &(*desc_head)->desc;
    sah_Head_Desc *desc_head_ptr = (sah_Head_Desc *)desc_ptr;

    while (desc_ptr != NULL) {
        register sah_Desc *next_desc_ptr;

        if (desc_ptr->ptr1 != NULL) {
            sah_Destroy_Link(mu, desc_ptr->ptr1);
        }
        if (desc_ptr->ptr2 != NULL) {
            sah_Destroy_Link(mu, desc_ptr->ptr2);
        }

        next_desc_ptr = desc_ptr->next;

        /* Be sure to free head descriptor as such */
        if (desc_ptr == (sah_Desc*)desc_head_ptr) {
            mu->mu_free_head_desc(mu->mu_ref, desc_head_ptr);
        } else {
            mu->mu_free_desc(mu->mu_ref, desc_ptr);
        }

        desc_ptr = next_desc_ptr;
    }

    *desc_head = NULL;
}


Generated by  Doxygen 1.6.0   Back to index