Cairo exports and more (was Re: [cairo] Re: Munging header files for export (and other) attributes)

Bill Spitzak spitzak at
Thu Sep 15 17:46:26 PDT 2005

Doodle wrote:

> To solve the initialization race, I think the only clean solution
> is to introduce new cairo_initialize() and cairo_uninitialize()
> functions

PLEASE NO!!!!!!!

All that is going to happen is people will put their own thread-unsafe 
wrappers around these calls. Or they will call them more than once, or 
not call them, and thus make code that does not work on multiple 
platforms. And if you think that making Cairo return an error in these 
cases is a good idea, it isn't, because you have now added exactly the 
same amount of overhead code (an if on every function) that the 
no-initialize version would need.

This is ALWAYS a bad idea, and is why modern programs take so horridly 
long to start up. Please don't do this!!!!

Use a mutex (and use that DLLInit to initialize the mutex) and put it in 
the back end functions that need to lock and initialize something:

_cairo_backend_foo() {
   static char been_here = false;
   if (!been_here) {
     if (!been_here) {
       been_here = true;

More information about the cairo mailing list