Subj : Re: returning arguments To : comp.programming.threads From : Huub Date : Wed Jun 29 2005 03:20 pm Joe Seigh wrote: > Huub wrote: > >> I *thought* I understood it. Could you explain a bit more of the last >> part of your comment please, including the casting to a pointer to the >> structure? >> Do you mean something like this: >> >> void *LeesSensoren(void *threadid) >> { >> ... >> displaygegevens = dg; >> ... >> return (void*)&dg; >> } >> >> void x() >> { >> ... >> pthread_join(threads[t], &retp); >> (*dg)*retp; >> rookstatus = dg.rookstatus; >> gasstatus = dg.gasstatus; >> temperatuur = dg.temperatuur; >> } >> >> Thank you for helping, >> >> Huub > > > > void *LeesSensoren(void *threadid) > { > struct displaygegevens *dg > ... > dg = (struct displaygegevens *)malloc(sizeof(struct displaygegevens)); > ... > return (void*)dg; > } > > void x() > { > struct displaygegevens *dg > > pthreadcreate(&threads[t],NULL , &LeesSensoren, &threadid[t]); > ... > pthread_join(threads[t], (void **)&dg); > rookstatus = dg->rookstatus; > gasstatus = dg->gasstatus; > temperatuur = dg->temperatuur; > > free(dg); > } > > Something like that. > Thank you. Since my source on threads is offline: do I have to use free(..) after pthread_join(..,..);? .