upiwin/src/gfxobj.c
2019-12-10 12:42:58 -07:00

40 lines
642 B
C
Executable File

#include <stdlib.h>
#include <string.h>
#include "gfxobj.h"
void _Go_init(PGFXOBJECT obj, UINT32 sig, UINT32 size)
{
memset(obj, 0, sizeof(GFXOBJECT));
obj->sig = sig;
obj->size = size;
obj->refcnt = 1;
}
void Go_unchain(PGFXOBJECT obj)
{
if (!(obj->next || obj->prev))
return;
if (obj->next)
obj->next->prev = obj->prev;
if (obj->prev)
obj->prev->next = obj->next;
obj->prev = obj->next = NULL;
}
INT32 Go_addref(PGFXOBJECT obj)
{
return ++(obj->refcnt);
}
INT32 Go_release(PGFXOBJECT obj)
{
int rc = --(obj->refcnt);
if (rc == 0)
{
if (obj->dtor)
(*(obj->dtor))(obj);
free(obj);
}
return rc;
}