registerSPForward now returing -1 if no func found

This commit is contained in:
Pavol Marko 2004-09-09 15:05:06 +00:00
parent 388915e6f8
commit 1df654c6a1

View File

@ -293,8 +293,10 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
if (!m_FreeSPForwards.empty()) if (!m_FreeSPForwards.empty())
{ {
pForward = m_SPForwards[m_FreeSPForwards.front() >> 1]; pForward = m_SPForwards[m_FreeSPForwards.front() >> 1];
m_FreeSPForwards.pop();
pForward->Set(func, amx, numParams, paramTypes); pForward->Set(func, amx, numParams, paramTypes);
if (pForward->getFuncsNum() == 0)
return -1;
m_FreeSPForwards.pop();
} }
else else
{ {
@ -302,12 +304,13 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
if (!pForward) if (!pForward)
return -1; return -1;
pForward->Set(func, amx, numParams, paramTypes); pForward->Set(func, amx, numParams, paramTypes);
m_SPForwards.push_back(pForward);
}
if (pForward->getFuncsNum() == 0) if (pForward->getFuncsNum() == 0)
{ {
unregisterSPForward(retVal);
return -1; return -1;
delete pForward;
}
m_SPForwards.push_back(pForward);
} }
return retVal; return retVal;
} }
@ -319,9 +322,11 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam
if (!m_FreeSPForwards.empty()) if (!m_FreeSPForwards.empty())
{ {
retVal = m_FreeSPForwards.front(); retVal = m_FreeSPForwards.front();
m_FreeSPForwards.pop();
pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag
pForward->Set(funcName, amx, numParams, paramTypes); pForward->Set(funcName, amx, numParams, paramTypes);
if (pForward->getFuncsNum() == 0)
return -1;
m_FreeSPForwards.pop();
} }
else else
{ {
@ -329,6 +334,11 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam
if (!pForward) if (!pForward)
return -1; return -1;
pForward->Set(funcName, amx, numParams, paramTypes); pForward->Set(funcName, amx, numParams, paramTypes);
if (pForward->getFuncsNum() == 0)
{
delete pForward;
return -1;
}
m_SPForwards.push_back(pForward); m_SPForwards.push_back(pForward);
} }
return retVal; return retVal;