I have a client-server program in which I need to accept connections of multiple clients and create a thread to serve each one of them.
I don't know from before the number of the threads that have to be created so for every connection I have to allocate space.
Here's what I do
The above is in a while loop and allocates space for the first thread and then creates it.
if (( tids = new pthread_t (sizeof ( pthread_t )) ) == NULL )
tids+1=new pthread_t (sizeof ( pthread_t ));
cout<<"error with realloc"<<endl;*/
For every new connection it allocates space for a new thread(thread_counter>0) and creates it.
The problem seems to appear with the pthread_create for the second thread etc.
(The program is compiled with g++ and that's why new is used,but vectors are not allowed so the rest of the program is in C)