fixed ds-graphscan test to make sure that the memory block size is large enough to...
authorVadim Pisarevsky <no@email>
Thu, 21 Oct 2010 12:26:11 +0000 (12:26 +0000)
committerVadim Pisarevsky <no@email>
Thu, 21 Oct 2010 12:26:11 +0000 (12:26 +0000)
tests/cxcore/src/adatastruct.cpp

index 74c9547..fbccab7 100644 (file)
@@ -2009,7 +2009,7 @@ void CxCore_GraphTest::run( int )
         struct_idx = iter = -1;
         t = cvTsRandReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size;
         int block_size = cvRound( exp(t * CV_LOG2) );
-        block_size = MAX(block_size, (int)(sizeof(CvGraph) + sizeof(CvMemBlock)));
+        block_size = MAX(block_size, (int)(sizeof(CvGraph) + sizeof(CvMemBlock) + sizeof(CvSeqBlock)));
         
         storage = cvCreateMemStorage(block_size);
 
@@ -2138,7 +2138,11 @@ void CxCore_GraphScanTest::run( int )
     {
         struct_idx = iter = -1;
         t = cvTsRandReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size;
-        storage = cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) );
+        int storage_blocksize = cvRound( exp(t * CV_LOG2) );
+        storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraph) + sizeof(CvMemBlock) + sizeof(CvSeqBlock)));
+        storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraphEdge) + sizeof(CvMemBlock) + sizeof(CvSeqBlock)));
+        storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraphVtx) + sizeof(CvMemBlock) + sizeof(CvSeqBlock)));
+        storage = cvCreateMemStorage(storage_blocksize);
 
         if( gen == 0 )
         {