[Bug 25108] Critical sections used without calling the initialization function

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Nov 11 06:36:48 CST 2010


http://bugs.winehq.org/show_bug.cgi?id=25108

--- Comment #4 from Eric <8jmtfa1e at gmail.com> 2010-11-11 06:36:44 CST ---
(In reply to comment #2)
> Critical sections can be statically initialized instead of calling
> InitializeCriticalSection(), that's perfectly acceptable.

I would call it undefined behaviour. No one outside of critsection.c should
know it's internal configurations. That's why there's an initializations
function. The purpose of the function is to make sure that internal changes
should not effect other parts of the project. Initializing the structure
elsewhere is insane and it's not considered a good coding practice.


Even Microsoft agrees with me. Reading from this document

http://msdn.microsoft.com/en-us/magazine/cc164040.aspx

you'll find this quote

"The life of a critical section begins when it's passed to
InitializeCriticalSection (or more accurately, when its address is passed).
Once initialized, your code passes the critical section to the
EnterCriticalSection and LeaveCriticalSection APIs."

Notice that they never mentions statically initialized structures. That's
because a programmer would never consider doing such a thing unless there's
absolutely no other way to solve the problem. It's one of the basic principles
of objective oriented programming.

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list