forked from boostorg/container
Support GCC's -Wconversion -Wfloat-conversion -Warith-conversion -Wsign-conversion warnings.
This commit is contained in:
+72
-72
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace boost { namespace container { namespace test {
|
||||
|
||||
static const int NumIt = 200;
|
||||
static const std::size_t NumIt = 200;
|
||||
|
||||
enum deallocation_type { DirectDeallocation, InverseDeallocation, MixedDeallocation, EndDeallocationType };
|
||||
|
||||
@@ -39,7 +39,7 @@ bool test_allocation()
|
||||
std::vector<void*> buffers;
|
||||
//std::size_t free_memory = a.get_free_memory();
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -49,7 +49,7 @@ bool test_allocation()
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -58,7 +58,7 @@ bool test_allocation()
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
for(std::size_t j = buffers.size()
|
||||
;j--
|
||||
;){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -67,12 +67,12 @@ bool test_allocation()
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4)*(buffers.size())/4;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -99,15 +99,15 @@ bool test_allocation_shrink()
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i*2);
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i*2u);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now shrink to half
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
;i < max
|
||||
; ++i){
|
||||
std::size_t try_received_size = 0;
|
||||
@@ -137,12 +137,12 @@ bool test_allocation_shrink()
|
||||
}
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
dlmalloc_malloc_check();
|
||||
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
@@ -158,7 +158,7 @@ bool test_allocation_expand()
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -166,7 +166,7 @@ bool test_allocation_expand()
|
||||
}
|
||||
|
||||
//Now try to expand to the double of the size
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
std::size_t received_size = 0;
|
||||
@@ -187,12 +187,12 @@ bool test_allocation_expand()
|
||||
}
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
dlmalloc_malloc_check();
|
||||
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
@@ -208,13 +208,13 @@ bool test_allocation_shrink_and_expand()
|
||||
std::vector<bool> size_reduced;
|
||||
|
||||
//Allocate buffers wand store received sizes
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
std::size_t received_size = 0;
|
||||
void *ptr = dlmalloc_allocation_command
|
||||
(BOOST_CONTAINER_ALLOCATE_NEW, 1, i, i*2, &received_size, 0).first;
|
||||
(BOOST_CONTAINER_ALLOCATE_NEW, 1u, i, i*2u, &received_size, 0).first;
|
||||
if(!ptr){
|
||||
ptr = dlmalloc_allocation_command
|
||||
( BOOST_CONTAINER_ALLOCATE_NEW, 1, 1, i*2, &received_size, 0).first;
|
||||
( BOOST_CONTAINER_ALLOCATE_NEW, 1u, 1u, i*2, &received_size, 0).first;
|
||||
if(!ptr)
|
||||
break;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ bool test_allocation_shrink_and_expand()
|
||||
}
|
||||
|
||||
//Now shrink to half
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
; i < max
|
||||
; ++i){
|
||||
std::size_t received_size = 0;
|
||||
@@ -243,7 +243,7 @@ bool test_allocation_shrink_and_expand()
|
||||
}
|
||||
|
||||
//Now try to expand to the original size
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(!size_reduced[i]) continue;
|
||||
@@ -262,12 +262,12 @@ bool test_allocation_shrink_and_expand()
|
||||
}
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
|
||||
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
@@ -284,7 +284,7 @@ bool test_allocation_deallocation_expand()
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -293,7 +293,7 @@ bool test_allocation_deallocation_expand()
|
||||
|
||||
//Now deallocate the half of the blocks
|
||||
//so expand maybe can merge new free blocks
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(i%2){
|
||||
@@ -303,7 +303,7 @@ bool test_allocation_deallocation_expand()
|
||||
}
|
||||
|
||||
//Now try to expand to the double of the size
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
//
|
||||
@@ -332,12 +332,12 @@ bool test_allocation_deallocation_expand()
|
||||
,buffers.end());
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
dlmalloc_malloc_check();
|
||||
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
@@ -354,11 +354,11 @@ bool test_allocation_with_reuse()
|
||||
{
|
||||
dlmalloc_malloc_check();
|
||||
//We will repeat this test for different sized elements
|
||||
for(int sizeof_object = 1; sizeof_object < 20; ++sizeof_object){
|
||||
for(std::size_t sizeof_object = 1; sizeof_object < 20; ++sizeof_object){
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i*sizeof_object);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -367,7 +367,7 @@ bool test_allocation_with_reuse()
|
||||
|
||||
//Now deallocate all except the latest
|
||||
//Now try to expand to the double of the size
|
||||
for(int i = 0, max = (int)buffers.size() - 1
|
||||
for(std::size_t i = 0, max = buffers.size() - 1
|
||||
;i < max
|
||||
;++i){
|
||||
dlmalloc_free(buffers[i]);
|
||||
@@ -379,9 +379,9 @@ bool test_allocation_with_reuse()
|
||||
|
||||
//Now allocate with reuse
|
||||
std::size_t received_size = 0;
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
std::size_t min_size = (received_size/sizeof_object + 1)*sizeof_object;
|
||||
std::size_t prf_size = (received_size/sizeof_object + (i+1)*2)*sizeof_object;
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
std::size_t min_size = (received_size/sizeof_object + 1u)*sizeof_object;
|
||||
std::size_t prf_size = (received_size/sizeof_object + (i+1u)*2u)*sizeof_object;
|
||||
dlmalloc_command_ret_t ret = dlmalloc_allocation_command
|
||||
( BOOST_CONTAINER_EXPAND_BWD, sizeof_object, min_size
|
||||
, prf_size, &received_size, (char*)ptr);
|
||||
@@ -413,8 +413,8 @@ bool test_aligned_allocation()
|
||||
dlmalloc_malloc_check();
|
||||
//Allocate aligned buffers in a loop
|
||||
//and then deallocate it
|
||||
for(unsigned int i = 1; i != (1 << (sizeof(int)/2)); i <<= 1){
|
||||
for(unsigned int j = 1; j != 512; j <<= 1){
|
||||
for(std::size_t i = 1u; i != (1u << (sizeof(int)/2u)); i <<= 1u){
|
||||
for(std::size_t j = 1u; j != 512u; j <<= 1){
|
||||
void *ptr = dlmalloc_memalign(i-1, j);
|
||||
if(!ptr){
|
||||
return false;
|
||||
@@ -442,11 +442,11 @@ bool test_continuous_aligned_allocation()
|
||||
//Allocate aligned buffers in a loop
|
||||
//and then deallocate it
|
||||
bool continue_loop = true;
|
||||
unsigned int MaxAlign = 4096;
|
||||
unsigned int MaxSize = 4096;
|
||||
for(unsigned i = 1; i < MaxSize; i <<= 1){
|
||||
for(unsigned int j = 1; j < MaxAlign; j <<= 1){
|
||||
for(int k = 0; k != NumIt; ++k){
|
||||
std::size_t MaxAlign = 4096;
|
||||
std::size_t MaxSize = 4096;
|
||||
for(std::size_t i = 1; i < MaxSize; i <<= 1){
|
||||
for(std::size_t j = 1; j < MaxAlign; j <<= 1){
|
||||
for(std::size_t k = 0; k != NumIt; ++k){
|
||||
void *ptr = dlmalloc_memalign(i-1, j);
|
||||
buffers.push_back(ptr);
|
||||
if(!ptr){
|
||||
@@ -458,7 +458,7 @@ bool test_continuous_aligned_allocation()
|
||||
return false;
|
||||
}
|
||||
//Deallocate all
|
||||
for(int k = (int)buffers.size(); k--;){
|
||||
for(std::size_t k = buffers.size(); k--;){
|
||||
dlmalloc_free(buffers[k]);
|
||||
}
|
||||
buffers.clear();
|
||||
@@ -485,7 +485,7 @@ bool test_many_equal_allocation()
|
||||
std::vector<void*> buffers2;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -496,7 +496,7 @@ bool test_many_equal_allocation()
|
||||
|
||||
//Now deallocate the half of the blocks
|
||||
//so expand maybe can merge new free blocks
|
||||
for(int i = 0, max = (int)buffers2.size()
|
||||
for(std::size_t i = 0, max = buffers2.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(i%2){
|
||||
@@ -509,7 +509,7 @@ bool test_many_equal_allocation()
|
||||
//return false;
|
||||
|
||||
std::vector<void*> buffers;
|
||||
for(int i = 0; i != NumIt/10; ++i){
|
||||
for(std::size_t i = 0; i != NumIt/10; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
dlmalloc_multialloc_nodes((i+1)*2, i+1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
@@ -532,7 +532,7 @@ bool test_many_equal_allocation()
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -541,7 +541,7 @@ bool test_many_equal_allocation()
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
for(std::size_t j = buffers.size()
|
||||
;j--
|
||||
;){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -550,12 +550,12 @@ bool test_many_equal_allocation()
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -566,12 +566,12 @@ bool test_many_equal_allocation()
|
||||
//Deallocate the rest of the blocks
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers2.size()
|
||||
for(std::size_t j = 0, max = buffers2.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers2.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers2.size())/4u;
|
||||
dlmalloc_free(buffers2[pos]);
|
||||
buffers2.erase(buffers2.begin()+pos);
|
||||
buffers2.erase(buffers2.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
|
||||
//bool ok = free_memory == a.get_free_memory() &&
|
||||
@@ -602,7 +602,7 @@ bool test_many_different_allocation()
|
||||
std::vector<void*> buffers2;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -611,7 +611,7 @@ bool test_many_different_allocation()
|
||||
|
||||
//Now deallocate the half of the blocks
|
||||
//so expand maybe can merge new free blocks
|
||||
for(int i = 0, max = (int)buffers2.size()
|
||||
for(std::size_t i = 0, max = buffers2.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(i%2){
|
||||
@@ -621,7 +621,7 @@ bool test_many_different_allocation()
|
||||
}
|
||||
|
||||
std::vector<void*> buffers;
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
dlmalloc_multialloc_arrays(ArraySize, requested_sizes, 1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
@@ -640,7 +640,7 @@ bool test_many_different_allocation()
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -649,7 +649,7 @@ bool test_many_different_allocation()
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
for(std::size_t j = buffers.size()
|
||||
;j--
|
||||
;){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -658,12 +658,12 @@ bool test_many_different_allocation()
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4)*(buffers.size())/4;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -674,12 +674,12 @@ bool test_many_different_allocation()
|
||||
//Deallocate the rest of the blocks
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers2.size()
|
||||
for(std::size_t j = 0, max = buffers2.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers2.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers2.size())/4u;
|
||||
dlmalloc_free(buffers2[pos]);
|
||||
buffers2.erase(buffers2.begin()+pos);
|
||||
buffers2.erase(buffers2.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
|
||||
//bool ok = free_memory == a.get_free_memory() &&
|
||||
@@ -699,7 +699,7 @@ bool test_many_deallocation()
|
||||
requested_sizes[i] = 4*i;
|
||||
}
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
dlmalloc_multialloc_arrays(ArraySize, requested_sizes, 1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
@@ -708,7 +708,7 @@ bool test_many_deallocation()
|
||||
return false;
|
||||
buffers.push_back(chain);
|
||||
}
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_multidealloc(&buffers[i]);
|
||||
}
|
||||
buffers.clear();
|
||||
@@ -717,7 +717,7 @@ bool test_many_deallocation()
|
||||
if(!dlmalloc_all_deallocated())
|
||||
return false;
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
dlmalloc_multialloc_nodes(ArraySize, i*4+1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
@@ -726,7 +726,7 @@ bool test_many_deallocation()
|
||||
return false;
|
||||
buffers.push_back(chain);
|
||||
}
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_multidealloc(&buffers[i]);
|
||||
}
|
||||
buffers.clear();
|
||||
|
||||
Reference in New Issue
Block a user