[complement-svn] SF.net SVN: complement: [1463] trunk/complement/explore/test/mt/mt_test.cc
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2006-12-26 16:32:33
|
Revision: 1463 http://svn.sourceforge.net/complement/?rev=1463&view=rev Author: complement Date: 2006-12-26 08:32:32 -0800 (Tue, 26 Dec 2006) Log Message: ----------- check more deallocation sequences Modified Paths: -------------- trunk/complement/explore/test/mt/mt_test.cc Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2006-12-26 16:13:00 UTC (rev 1462) +++ trunk/complement/explore/test/mt/mt_test.cc 2006-12-26 16:32:32 UTC (rev 1463) @@ -226,34 +226,59 @@ { xmt::allocator_shm<char,0> shmall; size_t sz = shmall.max_size(); + // two blocks char *ch1 = shmall.allocate( 3500 ); BOOST_CHECK( ch1 != 0 ); char *ch2 = shmall.allocate( 3500 ); BOOST_CHECK( ch2 != 0 ); try { + // try to allocate third block, not enough room char *ch3 = shmall.allocate( 8 * 1024 - 7000 ); BOOST_CHECK( false ); } catch ( xmt::shm_bad_alloc& err ) { BOOST_CHECK( true ); } + // free first blocks shmall.deallocate( ch1, 3500 ); ch1 = shmall.allocate( 3500 ); + // allocate [first] block again BOOST_CHECK( ch1 != 0 ); + // free second block shmall.deallocate( ch2, 3500 ); + // allocate [second] block again ch2 = shmall.allocate( 3500 ); BOOST_CHECK( ch2 != 0 ); + // free both blocks shmall.deallocate( ch1, 3500 ); shmall.deallocate( ch2, 3500 ); + // allocate big block, enough for initial memory chunk ch1 = shmall.allocate( 7000 ); BOOST_CHECK( ch1 != 0 ); + // free it shmall.deallocate( ch1, 7000 ); + // allocate block of maximum size ch1 = shmall.allocate( sz ); BOOST_CHECK( ch1 != 0 ); + // free it shmall.deallocate( ch1, sz ); + // allocate block, enough for initial memory chunk ch1 = shmall.allocate( 7000 ); BOOST_CHECK( ch1 != 0 ); + // free it shmall.deallocate( ch1, 7000 ); + ch1 = shmall.allocate( 3000 ); + BOOST_CHECK( ch1 != 0 ); + ch2 = shmall.allocate( 400 ); + BOOST_CHECK( ch2 != 0 ); + char *ch3 = shmall.allocate( 3500 ); + BOOST_CHECK( ch3 != 0 ); + shmall.deallocate( ch1, 3000 ); + shmall.deallocate( ch2, 400 ); + shmall.deallocate( ch3, 3500 ); + ch1 = shmall.allocate( sz ); + BOOST_CHECK( ch1 != 0 ); + shmall.deallocate( ch1, sz ); } seg.deallocate(); fs::remove( fname ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |