~ubuntu-branches/ubuntu/lucid/transmission/lucid

« back to all changes in this revision

Viewing changes to libtransmission/bitfield.h

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda, Krzysztof Klimonda, Chris Coulson
  • Date: 2009-12-11 11:46:59 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20091211114659-6ebcmonweaixdpl3
Tags: 1.80~b5-0ubuntu1
[ Krzysztof Klimonda ]
* New upstream release (LP: #496503)
* Refreshed 99_autoreconf.patch
* Removed 21_fix_inhibition.patch

[ Chris Coulson ]
* Drop debian/patches/CVE-2010-0012.patch - merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * This file Copyright (C) 2009 Mnemosyne LLC
 
2
 * This file Copyright (C) 2009-2010 Mnemosyne LLC
3
3
 *
4
4
 * This file is licensed by the GPL version 2.  Works owned by the
5
5
 * Transmission project are granted a special exemption to clause 2(b)
32
32
 
33
33
tr_bitfield* tr_bitfieldDestruct( tr_bitfield* );
34
34
 
35
 
static TR_INLINE tr_bitfield* tr_bitfieldNew( size_t bitcount )
 
35
static inline tr_bitfield* tr_bitfieldNew( size_t bitcount )
36
36
{
37
37
    return tr_bitfieldConstruct( tr_new0( tr_bitfield, 1 ), bitcount );
38
38
}
39
39
 
40
 
static TR_INLINE void tr_bitfieldFree( tr_bitfield * b )
 
40
static inline void tr_bitfieldFree( tr_bitfield * b )
41
41
{
42
42
    tr_free( tr_bitfieldDestruct( b ) );
43
43
}
67
67
    has none of tr_bitfieldHas()'s safety checks, so you
68
68
    need to call tr_bitfieldTestFast() first before you
69
69
    start looping. */
70
 
static TR_INLINE tr_bool tr_bitfieldHasFast( const tr_bitfield * b, const size_t nth )
 
70
static inline tr_bool tr_bitfieldHasFast( const tr_bitfield * b, const size_t nth )
71
71
{
72
72
    return ( b->bits[nth>>3u] << ( nth & 7u ) & 0x80 ) != 0;
73
73
}
74
74
 
75
75
/** @param high the highest nth bit you're going to access */
76
 
static TR_INLINE tr_bool tr_bitfieldTestFast( const tr_bitfield * b, const size_t high )
 
76
static inline tr_bool tr_bitfieldTestFast( const tr_bitfield * b, const size_t high )
77
77
{
78
78
    return ( b != NULL )
79
79
        && ( b->bits != NULL )
80
80
        && ( high < b->bitCount );
81
81
}
82
82
 
83
 
static TR_INLINE tr_bool tr_bitfieldHas( const tr_bitfield * b, size_t nth )
 
83
static inline tr_bool tr_bitfieldHas( const tr_bitfield * b, size_t nth )
84
84
{
85
85
    return tr_bitfieldTestFast( b, nth ) && tr_bitfieldHasFast( b, nth );
86
86
}