gs_cbase.cpp
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "gs_cbase.h"
GS_CBase::~GS_CBase()
{
gs_destroy_service_callback(this);
}
GS_CBase::GS_CBase(U32 handle)
{
m_handle = handle;
refCount = 0;
gs_create_service_callback(this);
}
S32 CALLCC GS_CBase::addRef()
{
refCount ++;
return refCount;
}
S32 CALLCC GS_CBase::release()
{
//MMI_TRACE(MMI_MRE_TRC_G6, TRC_MMI_GETSRV_CBASE_RELEASE);
gs_memory_set_handle(m_handle);
if(refCount == 0) return 0;
refCount--;
if (refCount == 0)
{
const GS_CBase* _this = this;
GS_DEL(_this);
return 0;
}
return refCount;
}
S32 CALLCC GS_CBase::queryInterface(S32 iid, GS_IBase** pptr)
{
if (pptr == NULL) return 0;
if (iid == IID_GS_IBASE)
{
addRef();
*pptr = BIND_PROXY(GS_IBase, this);
return 1;
}
return 0;
}
void* GS_CBase::operator new (unsigned int size)
{
gs_assert(0); // should not call this
return NULL;
}
void* GS_CBase::operator new (unsigned int size, void *buf)
{
return buf;
}
void GS_CBase::operator delete (void* ptr)
{
gs_free(ptr);
}