Subj : dynamic allocation, deallocation but not heap fragmentation! To : comp.programming.threads From : jimjim Date : Fri May 13 2005 07:50 pm Hello, I am developing a multithreaded web server. I am using pthreads. The pthread_create( ) takes "pthread_t *thread" & "void *arg" as two of the arguments. For "void *arg" I intend to pass the user-defined structure struct info {int clisockfd; struct sockaddr_in cliaddr }. In the main thread, after accept( ) returns as a client has connected, I am populating the struct info with the int clisockfd, which is the connecting client's file descriptor returned by accept( ), and the "struct sockaddr_in cliaddr", which as you guessed it is the struct passed to accept( ) and contains the client's IP address, port etc. My problem is that I cant really think of an effective way that I can create "struct info" dynamically, pass them to created threads and deallocate the memory when the threads terminate without perhaps fragmenting the heap after some thousands of hits. Moreover, how is it possible to create and delete dynamically the "pthread_t" ? Any pointers are very much wellcome. Thank you in advance. Regards, jimjim .