Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Bug in concurrent_vector documentation

michaelmarcin
Beginner
252 Views
Section 5.2 of the Tutorial (Open Source).pdf on the website contains the following code snippet.

void Append( concurrent_vector& vector, const char* string ) {
size_t n = strlen(string)+1;
memcpy( &vector[vector.grow_by(n)], string, n+1 );
}

Isn't this copying the null terminated string plus an additional byte to the vector?
0 Kudos
1 Reply
Andrey_Marochko
New Contributor III
252 Views
Thanks for catching and reporting the error! Though it looks like someone has already fixed it by rewriting the memcpy line in the following way

std::copy( string, string+n, vector.begin()+vector.grow_by(n) );

Not sure if this version has already been released, but at least it is what I see in our mainline at the moment. Anyway, thanks again, and don't hesitate posting other errors you may find (you evidently have a sharp eye), there is a good chance that they are still lying about nonfixedsmiley [:-)].

0 Kudos
Reply