For example, I have a variable
struct sth {
int abcd;
pthread_mutex_t mutex;
};
I have two method
setSth(int a) {
lock();
sth->abcd = a;
unlock();
}
getSth() {
return sth->abcd;
}
sth
will never be freed. Is it safe not use lock/unlock
in getSth()? I don't care accuracy.
By safe I mean there's no segfault thing.