merge bitfield fix from RC_1_0 (although, fix doesn't apply)

This commit is contained in:
Arvid Norberg 2014-07-28 04:41:40 +00:00
parent 035da93592
commit fb23601898
3 changed files with 26 additions and 1 deletions

View File

@ -27,6 +27,7 @@
* almost completely changed the storage interface (for custom storage)
* added support for hashing pieces in multiple threads
* fix alignment issue in bitfield
* improved error handling of gzip
* fixed crash when web seeds redirect
* fix compiler warnings

View File

@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
// The bitfiled type stores any number of bits as a bitfield
// in a heap allocated or borrowed array.
// in a heap allocated array.
struct TORRENT_EXPORT bitfield
{
// constructs a new bitfield. The default constructor creates an empty

View File

@ -164,5 +164,29 @@ int test_main()
test1.resize(i, false);
test_iterators(test1);
}
// test alignment
boost::uint32_t buffer[4];
char* b = (char*)buffer;
for (int i = 0; i < 4; ++i)
{
b[i] = 0xc0;
test1.assign(b + i, 2);
print_bitfield(test1);
TEST_EQUAL(test1.count(), 2);
TEST_EQUAL(test1.all_set(), true);
}
for (int i = 0; i < 4; ++i)
{
memset(b + i, 0xff, 5);
b[i + 5] = 0xc0;
test1.assign(b + i, 32 + 8 + 2);
print_bitfield(test1);
TEST_EQUAL(test1.count(), 32 + 8 + 2);
TEST_EQUAL(test1.all_set(), true);
}
return 0;
}