It's more complicated that that. I simplified the example...
I'm passing this structure:
Code:
typedef struct { /* Country mutex structure */
pthread_mutex_t resA, resE, resP, resM;
pthread_mutex_t purchase1, purchase2;
} CountryMutex;
Into this function:
Code:
void findDeficit(const Config *config, const CountryStruct *country, CountryDeficit *cdeficit, CountryMutex *cmutex) {
pthread_mutex_lock(&cmutex->resA);
...
pthread_mutex_unlock(&cmutex->resA);
}
Using this call:
Code:
CountryMutex cmutex;
pthread_mutex_init(&cmutex.resA, NULL);
pthread_mutex_init(&cmutex.resE, NULL);
pthread_mutex_init(&cmutex.resP, NULL);
pthread_mutex_init(&cmutex.resM, NULL);
findDeficit(config, country, cdeficit, &cmutex); << EDIT
Shouldn't this work? Passing a pointer to a structure of mutexes?