mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 05:53:40 +00:00
[host] dxgi: check for correct comRef usage
This commit is contained in:
parent
c591f7a8ae
commit
52410beea7
@ -32,12 +32,16 @@ typedef struct
|
||||
}
|
||||
COMRef;
|
||||
|
||||
static bool comInit = false;
|
||||
static int comScope = -1;
|
||||
static Vector comObjectsLocal = {0};
|
||||
static Vector comObjectsGlobal = {0};
|
||||
|
||||
bool comRef_init(unsigned globals, unsigned locals)
|
||||
{
|
||||
if (comInit)
|
||||
return true;
|
||||
|
||||
if (!vector_create(&comObjectsGlobal, sizeof(COMRef), globals))
|
||||
return false;
|
||||
|
||||
@ -47,11 +51,15 @@ bool comRef_init(unsigned globals, unsigned locals)
|
||||
return false;
|
||||
}
|
||||
|
||||
comInit = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void comRef_free(void)
|
||||
{
|
||||
if (!comInit)
|
||||
return;
|
||||
|
||||
COMRef * ref;
|
||||
|
||||
if (comScope > -1)
|
||||
@ -74,10 +82,13 @@ void comRef_free(void)
|
||||
comScope = -1;
|
||||
vector_destroy(&comObjectsLocal);
|
||||
vector_destroy(&comObjectsGlobal);
|
||||
comInit = false;
|
||||
}
|
||||
|
||||
static IUnknown ** comRef_new(Vector * vector, IUnknown *** dst)
|
||||
{
|
||||
DEBUG_ASSERT(comInit && "comRef has not been initialized");
|
||||
|
||||
// we must not allow the vector to grow as if the realloc moves to a new
|
||||
// address it will invalidate any external pointers to members in it
|
||||
DEBUG_ASSERT(vector_size(vector) < vector_capacity(vector) &&
|
||||
@ -112,10 +123,15 @@ IUnknown ** comRef_newLocal(IUnknown *** dst)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void comRef_scopePush(void) { ++comScope; }
|
||||
void comRef_scopePush(void)
|
||||
{
|
||||
DEBUG_ASSERT(comInit && "comRef has not been initialized");
|
||||
++comScope;
|
||||
}
|
||||
|
||||
void comRef_scopePop(void)
|
||||
{
|
||||
DEBUG_ASSERT(comInit && "comRef has not been initialized");
|
||||
DEBUG_ASSERT(comScope >= 0);
|
||||
|
||||
COMRef * ref;
|
||||
|
@ -58,6 +58,9 @@ IUnknown ** comRef_newLocal(IUnknown *** dst);
|
||||
*/
|
||||
inline static ULONG comRef_release(IUnknown ** ref)
|
||||
{
|
||||
if (!ref)
|
||||
return 0;
|
||||
|
||||
ULONG count = 0;
|
||||
if (*ref)
|
||||
count = IUnknown_Release(*ref);
|
||||
|
Loading…
Reference in New Issue
Block a user