2019-12-09 17:02:04 -07:00
|
|
|
#include <stdlib.h>
|
2019-12-10 12:42:58 -07:00
|
|
|
#include <string.h>
|
2019-12-09 17:02:04 -07:00
|
|
|
#include "gfxobj.h"
|
|
|
|
|
2019-12-10 12:42:58 -07:00
|
|
|
void _Go_init(PGFXOBJECT obj, UINT32 sig, UINT32 size)
|
|
|
|
{
|
|
|
|
memset(obj, 0, sizeof(GFXOBJECT));
|
|
|
|
obj->sig = sig;
|
|
|
|
obj->size = size;
|
|
|
|
obj->refcnt = 1;
|
|
|
|
}
|
|
|
|
|
2019-12-09 17:02:04 -07:00
|
|
|
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;
|
|
|
|
}
|