Skip to content

Commit 33aff86

Browse files
committed
Removed CCallback::Free. Now, dealloc() can be used to free the callback
1 parent 558ead9 commit 33aff86

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/core/modules/memory/memory_callback.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,17 @@ Param_t* CCallback::GetArgument(int iIndex)
147147
return temp;
148148
}
149149

150-
void CCallback::Free()
150+
void CCallback::Dealloc()
151151
{
152-
// TODO: Figure out how to use std::free() on the generated code, so we can
153-
// use Dealloc().
154152
MemoryManager::getGlobal()->free((void *) m_ulAddr);
155153
m_ulAddr = 0;
156154
}
157155

156+
void CCallback::Realloc(int iSize)
157+
{
158+
BOOST_RAISE_EXCEPTION(PyExc_NotImplementedError, "This function is not implemented for callbacks.")
159+
}
160+
158161

159162
// ============================================================================
160163
// >> FUNCTIONS

src/core/modules/memory/memory_callback.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class CCallback: public CFunction
7373
int GetPopSize();
7474
int GetArgumentCount();
7575
Param_t* GetArgument(int iIndex);
76-
void Free();
76+
77+
virtual void Dealloc();
78+
virtual void Realloc(int iSize);
7779

7880
public:
7981
// For variadic functions

src/core/modules/memory/memory_tools.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ class CPointer
189189

190190
CPointer* GetVirtualFunc(int iIndex);
191191

192-
void Realloc(int iSize) { m_ulAddr = (unsigned long) UTIL_Realloc((void *) m_ulAddr, iSize); }
193-
void Dealloc() { UTIL_Dealloc((void *) m_ulAddr); m_ulAddr = 0; }
192+
virtual void Realloc(int iSize) { m_ulAddr = (unsigned long) UTIL_Realloc((void *) m_ulAddr, iSize); }
193+
virtual void Dealloc() { UTIL_Dealloc((void *) m_ulAddr); m_ulAddr = 0; }
194194

195195
CFunction* MakeFunction(Convention_t eConv, char* szParams);
196196
CFunction* MakeVirtualFunction(int iIndex, Convention_t eConv, char* szParams);

src/core/modules/memory/memory_wrap_python.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,6 @@ void export_dynamichooks()
457457
void export_callbacks()
458458
{
459459
class_< CCallback, bases< CFunction > >("Callback", init< object, Convention_t, char * >())
460-
.def("free",
461-
&CCallback::Free,
462-
"Frees the callback. Don't use dealloc()!"
463-
)
464-
465460
.def_readwrite("callback",
466461
&CCallback::m_oCallback,
467462
"The Python function that gets called by the C++ callback"

0 commit comments

Comments
 (0)