_strdup can cause memory leaks
just cast it
#ifdef PYTHON_3
if (!PyUnicode_Check(poItem))
return false;
const char* temp = PyUnicode_AsUTF8(poItem);
if (temp == NULL)
return false;
*ret = (char*)temp;
#else
if (!PyString_Check(poItem))
return false;
*ret = PyString_AsString(poItem);
#endif
or use const char* for read-only
bool PyTuple_GetString(PyObject* poArgs, int pos, const char** ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
if (!PyUnicode_Check(poItem))
return false;
const char* str = PyUnicode_AsUTF8(poItem);
if (!str)
return false;
*ret = str;
return true;
}
Thanks for sharing!
EDIT:
Don't do this
In some instances, Destroy Window is called multiple times for that window.
void CWindowManager::DestroyWindow(CWindow* pWin)
{
if (std::find(m_ReserveDeleteWindowList.begin(), m_ReserveDeleteWindowList.end(), pWin) != m_ReserveDeleteWindowList.end())
{
TraceError("Double-destruction of %s %p", pWin->GetName(), pWin);
return;
}
[..]
}