I think I already know the answer to this, but I’m currently working on re-vamping some legacy Visual C++ 6.0 code, and I was working on putting in some CCriticalSections, But then I got thinking about it, if all my function does is return a pointer to some data, I think the critical sections is probably useless, because I don’t think im really protecting the data its pointing too, I don’t think it really stops anyone from writing to it. (assuming i have the same locks around the setter).
What do you think?
Yes if you are returning pointers to a data then deferencing the pointers outside the critical section would be a problem. Access to the critical shared data must be within the locks.