src/imap/imap.c
/*
 * Destroy imap with optional call-back function.
 */
Destroy imap with optional call-back function.
Destroy imap with optional call - back function .
void imap_free(imap_t * imap, imap_free_cb cb)
{
    if (imap->len)
    {
        imap_node_t * nd;
        if (cb == NULL)
        {
            for (uint_fast8_t i = 0; i < IMAP_NODE_SZ; i++)
            {
                nd = imap->nodes + i;
                if (nd->nodes != NULL)
                {
                    IMAP_node_free(nd);
                }
            }
        }
        else
        {
            for (uint_fast8_t i = 0; i < IMAP_NODE_SZ; i++)
            {
                nd = imap->nodes + i;
                if (nd->data != NULL)
                {
                    (*cb)(nd->data);
                }
                if (nd->nodes != NULL)
                {
                    IMAP_node_free_cb(nd, cb);
                }
            }
        }
    }
    slist_free(imap->slist);
    free(imap);
}
void imap_free ( imap_t * imap , imap_free_cb cb ) { if ( imap -> len ) { imap_node_t * nd ; if ( cb == NULL ) { for ( uint_fast8_t i = 0 ; i < IMAP_NODE_SZ ; i ++ ) { nd = imap -> nodes + i ; if ( nd -> nodes != NULL ) { IMAP_node_free ( nd ) ; } } } else { for ( uint_fast8_t i = 0 ; i < IMAP_NODE_SZ ; i ++ ) { nd = imap -> nodes + i ; if ( nd -> data != NULL ) { ( * cb ) ( nd -> data ) ; } if ( nd -> nodes != NULL ) { IMAP_node_free_cb ( nd , cb ) ; } } } } slist_free ( imap -> slist ) ; free ( imap ) ; }
Destroy imap with optional call-back function.
Destroy imap with optional call - back function .