--- snip --- if (!ref) { EnterCriticalSection(...); list_remove(...); LeaveCriticalSection(...);
... }
--- snip ---
And when querying cached font faces:
--- snip --- EnterCriticalSection(...); LIST_FOR_EACH_ENTRY(...) { ...
/* the following code could also be hidden in QueryInterface */ if (InterlockedIncrement( &obj->refcount ) == 1) { InterlockedDecrement( &obj->refcount ); continue; } /* return it */ } LeaveCriticalSection(...);
--- snip ---
Doesn't the object just leak in this scenario though ? (assuming current refcount is 1) : ============= =========== Thread A Thread B ============= =========== enter_cs Increment Decrement ref != Zero Decrement leave_cs ============= ===========