src/imap/imap.c
/*
 * Use this function to create a s-list copy and update the ref count
 * for each object. We expect each object to have object->ref (uint_xxx_t) on
 * top of the object definition.
 *
 * There is no function to handle the decrement for the ref count since they
 * are different for each object. Best is to handle the decrement while looping
 * over the returned list.
 *
 * Returns NULL in case an error has occurred.
 */
Use this function to create a s-list copy and update the ref count
for each object. We expect each object to have object->ref (uint_xxx_t) on
top of the object definition.

There is no function to handle the decrement for the ref count since they
are different for each object. Best is to handle the decrement while looping
over the returned list.

Returns NULL in case an error has occurred.
Use this function to create a s - list copy and update the ref count for each object . We expect each object to have object - > ref ( uint_xxx_t ) on top of the object definition . There is no function to handle the decrement for the ref count since they are different for each object . Best is to handle the decrement while looping over the returned list . Returns NULL in case an error has occurred .
slist_t * imap_2slist_ref(imap_t * imap)
{
    if (imap->slist == NULL)
    {
        imap->slist = slist_new(imap->len);
        if (imap->slist != NULL && imap->len)
        {
            imap_node_t * nd;
            for (uint_fast8_t i = 0; i < IMAP_NODE_SZ; i++)
            {
                nd = imap->nodes + i;
                if (nd->data != NULL)
                {
                    slist_append(imap->slist, nd->data);
                    slist_object_incref(nd->data);
                }
                if (nd->nodes != NULL)
                {
                    IMAP_2slist_ref(nd, imap->slist);
                }
            }
        }
    }
    else
    {
        for (size_t i = 0; i < imap->slist->len; i++)
        {
            slist_object_incref(imap->slist->data[i]);
        }
    }
    return (imap->slist == NULL) ? NULL : slist_copy(imap->slist);
}
slist_t * imap_2slist_ref ( imap_t * imap ) { if ( imap -> slist == NULL ) { imap -> slist = slist_new ( imap -> len ) ; if ( imap -> slist != NULL && imap -> len ) { imap_node_t * nd ; for ( uint_fast8_t i = 0 ; i < IMAP_NODE_SZ ; i ++ ) { nd = imap -> nodes + i ; if ( nd -> data != NULL ) { slist_append ( imap -> slist , nd -> data ) ; slist_object_incref ( nd -> data ) ; } if ( nd -> nodes != NULL ) { IMAP_2slist_ref ( nd , imap -> slist ) ; } } } } else { for ( size_t i = 0 ; i < imap -> slist -> len ; i ++ ) { slist_object_incref ( imap -> slist -> data [ i ] ) ; } } return ( imap -> slist == NULL ) ? NULL : slist_copy ( imap -> slist ) ; }
Use this function to create a s-list copy and update the ref count
 for each object.
Use this function to create a s - list copy and update the ref count for each object .