From ebfd26fb75ffe3ab740e951dd3c683e336af56a0 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sun, 21 Aug 2016 09:50:05 +0000 Subject: [PATCH] #1207 Dynamically new/delete thread array in mt-test.cpp --- samples/mt-test.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/samples/mt-test.cpp b/samples/mt-test.cpp index 17711565..94168715 100644 --- a/samples/mt-test.cpp +++ b/samples/mt-test.cpp @@ -64,20 +64,19 @@ int main(int argc,const char* argv[]) Exiv2::XmpParser::initialize(); // bucket of threads - const int TMAX=1000; - std::thread threads[TMAX]; - int argm = argc > TMAX ? TMAX : argc; + std::thread* threads = new std::thread[argc+1]; // spin up the treads - for ( int arg = 1 ; arg < argm ; arg++ ) { + for ( int arg = 1 ; arg < argc ; arg++ ) { threads[arg] = std::thread(reportExifMetadataCount,arg,argv); } // wait for them to finish - for ( int arg = 1 ; arg < argm ; arg++ ) { + for ( int arg = 1 ; arg < argc ; arg++ ) { if ( threads[arg].joinable() ) threads[arg].join(); } + delete [] threads; } return result;