I suspect I am doing something dumb here but I am getting seg faults on an embedded Linux platform (GCC compiler) when I try to run pthread_rwlock_init() on a rwlock embedded in a structure.
struct rwlock_flag {
int flag; // Flag
pthread_rwlock_t * rwlock; // Reader/writer lock for flag
};
The following causes a seg fault...
struct rwlock_flag * running;
running = (struct rwlock_flag *) malloc (sizeof(struct rwlock_flag));
rslt = pthread_rwlock_init(running->rwlock, NULL);
As does this...
pthread_rwlock_t * rwlock_dg2;
pthread_rwlock_init(rwlock_dg2,NULL);
However the following works fine...
pthread_rwlock_t rwlock_dg;
pthread_rwlock_init(& rwlock_dg,NULL);
Any thoughts?