src/imap/imap.c
/*
 * Remove and return an item by id or return NULL in case the id is not found.
 */
Remove and return an item by id or return NULL in case the id is not found.
Remove and return an item by id or return NULL in case the id is not found .
void * imap_pop(imap_t * imap, uint64_t id)
{
    void * data;
    imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ);
    id /= IMAP_NODE_SZ;
    if (id)
    {
        data = (nd->nodes == NULL) ? NULL : IMAP_pop(nd, id - 1);
    }
    else if ((data = nd->data) != NULL)
    {
        nd->data = NULL;
    }
    if (data != NULL)
    {
        imap->len--;
        if (imap->slist != NULL)
        {
            slist_free(imap->slist);
            imap->slist = NULL;
        }
    }
    return data;
}
void * imap_pop ( imap_t * imap , uint64_t id ) { void * data ; imap_node_t * nd = imap -> nodes + ( id % IMAP_NODE_SZ ) ; id /= IMAP_NODE_SZ ; if ( id ) { data = ( nd -> nodes == NULL ) ? NULL : IMAP_pop ( nd , id - 1 ) ; } else if ( ( data = nd -> data ) != NULL ) { nd -> data = NULL ; } if ( data != NULL ) { imap -> len -- ; if ( imap -> slist != NULL ) { slist_free ( imap -> slist ) ; imap -> slist = NULL ; } } return data ; }
Remove and return an item by id or return NULL in case the id is not found.
Remove and return an item by id or return NULL in case the id is not found .