From e9659e563bbdcbced12df942c9426138596de111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 14 Jul 2014 23:31:16 +0200 Subject: [PATCH] Workaround for error in Intel compilers, avoid the static array --- proj/vc7ide/interprocesslib.vcproj | 3 +++ test/segment_manager_test.cpp | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/proj/vc7ide/interprocesslib.vcproj b/proj/vc7ide/interprocesslib.vcproj index 8440fd5..a3be7ea 100644 --- a/proj/vc7ide/interprocesslib.vcproj +++ b/proj/vc7ide/interprocesslib.vcproj @@ -693,6 +693,9 @@ + + diff --git a/test/segment_manager_test.cpp b/test/segment_manager_test.cpp index 78f5f73..bc46638 100644 --- a/test/segment_manager_test.cpp +++ b/test/segment_manager_test.cpp @@ -142,14 +142,29 @@ bool test_segment_manager() //Mark memory to non-zero std::memset(mem, 0xFF, Size); std::memset(mem2, 0xFF, Size2); - static unsigned char zerobuf[Size]; //Deallocate and check still non-zero seg_mgr->deallocate(mem); seg_mgr->deallocate(mem2); - if(!std::memcmp(mem, zerobuf, Size)) - return false; - if(!std::memcmp(mem2, zerobuf, Size2)) - return false; + { //Use byte per byte comparison as "static unsigned char zerobuf[Size]" + //seems to be problematic in some compilers + unsigned char *const mem_uch_ptr = static_cast(mem); + unsigned char *const mem2_uch_ptr = static_cast(mem2); + size_type zeroes = 0; + for(size_type i = 0; i != Size; ++i){ + if(!mem_uch_ptr[i]) + ++zeroes; + } + if(zeroes == Size) + return false; + + zeroes = 0; + for(size_type i = 0; i != Size2; ++i){ + if(!mem2_uch_ptr[i]) + ++zeroes; + } + if(zeroes == Size2) + return false; + } //zero_free_memory and check it's zeroed seg_mgr->zero_free_memory(); //TODO: some parts are not zeroed because they are used