fixed copy backs so they work properly

NOTE: heap fails, working on a rewrite

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40186
This commit is contained in:
David Anderson 2006-11-12 02:24:45 +00:00
parent 6bef3c2c5a
commit 94dc5ca298
3 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,7 @@ namespace SourceMod
#define SMFUNC_COPYBACK_NONE (0) /* Never copy an array back */
#define SMFUNC_COPYBACK_ONCE (1<<0) /* Copy an array back after call */
#define SMFUNC_COPYBACK_ALWAYS (1<<1) /* Copy an array back after subsequent calls (forwards) */
#define SMFUNC_ARRAY_NOINIT (1<<2) /* The array is not copied at first, but copyback is performed */
/**
* @brief Represents what a function needs to implement in order to be callable.

View File

@ -113,8 +113,11 @@ int CFunction::PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr
m_curparam++;
if (inarray)
{
if (!(copyback & SMFUNC_ARRAY_NOINIT))
{
memcpy(info->phys_addr, inarray, sizeof(cell_t) * cells);
}
info->orig_addr = inarray;
} else {
info->orig_addr = info->phys_addr;
@ -257,7 +260,7 @@ int CFunction::Execute(cell_t *result, IFunctionCopybackReader *reader)
}
}
_skipcopy:
base->HeapRelease(temp_info[numparams].local_addr);
base->HeapPop(temp_info[numparams].local_addr);
temp_info[numparams].marked = false;
}

View File

@ -418,7 +418,7 @@ void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags)
for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
{
func = (*iter);
func->PushArray(NULL, cells, NULL, flags);
func->PushArray(inarray, cells, NULL, flags|SMFUNC_ARRAY_NOINIT);
}
m_CopyBacks.recopy[m_CopyBacks.numrecopy++] = m_curparam;
m_CopyBacks.orig_addrs[m_curparam] = inarray;