Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Jan 19, 2023
1 parent 105030e commit fe27fe0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ascurl/ascurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class CBaseHTTPRequest

if (m_callback)
{
ASEXT_CASRefCountedBaseClass_InternalRelease(m_callback->getReference());
ASEXT_DereferenceCASFunction(m_callback);
}
}
virtual bool IsAsync() const = 0;
Expand Down
9 changes: 8 additions & 1 deletion asext/include/asext_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ class CASFunction
{
public:
#ifdef _WIN32
virtual void Release(char bFree) = 0;
#define CASFunction_dtor_firstarg 1
virtual void Release(char a1) = 0;
#else
#define CASFunction_dtor_firstarg
virtual void Unknown() = 0;
virtual void Release() = 0;
#endif
Expand All @@ -119,6 +121,11 @@ class CASFunction
int ref;
};

#define ASEXT_DereferenceCASFunction(callback) if (ASEXT_CASRefCountedBaseClass_InternalRelease(callback->getReference()))\
{\
callback->Release(CASFunction_dtor_firstarg);\
}

class CASServerManager
{
public:
Expand Down
7 changes: 2 additions & 5 deletions asqcvar/asqcvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ void ASQCvar_Shutdown()
{
auto callback = itor->second;

if (ASEXT_CASRefCountedBaseClass_InternalRelease(callback->getReference()))
{
callback->Release(1);
}
ASEXT_DereferenceCASFunction(callback);

itor = g_QueryCvar2Callbacks.erase(itor);
}
Expand Down Expand Up @@ -64,7 +61,7 @@ void ASQCvar_CallQueryCvar2Callback(void *pPlayer, int request_id, const char *c

if (ASEXT_CASRefCountedBaseClass_InternalRelease(callback->getReference()))
{
callback->Release(1);
ASEXT_DereferenceCASFunction(callback);
}

g_QueryCvar2Callbacks.erase(itor);
Expand Down

0 comments on commit fe27fe0

Please sign in to comment.