diff --git a/drd/tests/annotate_smart_pointer.cpp b/drd/tests/annotate_smart_pointer.cpp index bcf3a7840..433430222 100644 --- a/drd/tests/annotate_smart_pointer.cpp +++ b/drd/tests/annotate_smart_pointer.cpp @@ -29,6 +29,7 @@ #include // PTHREAD_STACK_MIN #include // std::cerr #include // atoi() +#include #ifdef _WIN32 #include // _beginthreadex() #include // CRITICAL_SECTION @@ -311,12 +312,11 @@ int main(int argc, char** argv) for (int j = 0; j < iterations; ++j) { - Thread T[nthreads]; - + std::vector T(nthreads); smart_ptr p(new counter); p->post_increment(); - for (int i = 0; i < nthreads; ++i) - T[i].Create(thread_func, new smart_ptr(p)); + for (std::vector::iterator q = T.begin(); q != T.end(); q++) + q->Create(thread_func, new smart_ptr(p)); { // Avoid that counter.m_mutex introduces a false ordering on the // counter.m_count accesses. @@ -324,8 +324,8 @@ int main(int argc, char** argv) nanosleep(&delay, 0); } p = NULL; - for (int i = 0; i < nthreads; ++i) - T[i].Join(); + for (std::vector::iterator q = T.begin(); q != T.end(); q++) + q->Join(); } std::cerr << "Done.\n"; return 0;