Пример #1
0
static void
dns_cache_clear_entry( struct tr_ptrArray * cache, const char * host )
{
    struct dns_cache_item key;
    key.host = (char*) host;
    dns_cache_item_free( tr_ptrArrayRemoveSorted( cache, &key, dns_cache_compare ) );
}
Пример #2
0
void
tr_bandwidthSetParent( tr_bandwidth  * b,
                       tr_bandwidth  * parent )
{
    assert( tr_isBandwidth( b ) );
    assert( b != parent );

    if( b->parent )
    {
        void * removed;

        assert( tr_isBandwidth( b->parent ) );

        removed = tr_ptrArrayRemoveSorted( &b->parent->children, b, comparePointers );
        assert( removed == b );
        assert( tr_ptrArrayFindSorted( &b->parent->children, b, comparePointers ) == NULL );

        b->parent = NULL;
    }

    if( parent )
    {
        assert( tr_isBandwidth( parent ) );
        assert( parent->parent != b );

        tr_ptrArrayInsertSorted( &parent->children, b, comparePointers );
        assert( tr_ptrArrayFindSorted( &parent->children, b, comparePointers ) == b );
        b->parent = parent;
    }
}
Пример #3
0
void
tr_bandwidthRemovePeer( tr_bandwidth  * b,
                        tr_peerIo     * peerIo )
{
    assert( tr_isBandwidth( b ) );
    assert( tr_isPeerIo( peerIo ) );

    tr_ptrArrayRemoveSorted( b->peers, peerIo, comparePointers );
}