core/HandleSys.cpp
changeset 2959 1a7109501676
parent 2638 71b35efbee34
child 3278 00388f39f24b
     1.1 --- a/core/HandleSys.cpp	Sat Apr 24 21:10:23 2010 -0400
     1.2 +++ b/core/HandleSys.cpp	Tue Apr 27 21:03:20 2010 -0700
     1.3 @@ -620,6 +620,43 @@
     1.4  	return CloneHandle(pHandle, index, newhandle, newOwner);
     1.5  }
     1.6  
     1.7 +Handle_t HandleSystem::FastCloneHandle(QHandle *pHandle, unsigned int index)
     1.8 +{
     1.9 +	if (pHandle->clone)
    1.10 +		return FastCloneHandle(&m_Handles[pHandle->clone], pHandle->clone);
    1.11 +
    1.12 +	Handle_t hndl;
    1.13 +	if (CloneHandle(pHandle, index, &hndl, g_pCoreIdent) != HandleError_None)
    1.14 +		return BAD_HANDLE;
    1.15 +
    1.16 +	return hndl;
    1.17 +}
    1.18 +
    1.19 +Handle_t HandleSystem::FastCloneHandle(Handle_t hndl)
    1.20 +{
    1.21 +	QHandle *pHandle;
    1.22 +	unsigned int index;
    1.23 +
    1.24 +	GetHandleUnchecked(hndl, pHandle, index);
    1.25 +
    1.26 +	return FastCloneHandle(pHandle, index);
    1.27 +}
    1.28 +
    1.29 +void HandleSystem::GetHandleUnchecked(Handle_t hndl, QHandle *& pHandle, unsigned int &index)
    1.30 +{
    1.31 +#ifndef NDEBUG
    1.32 +	unsigned int serial = (hndl >> 16);
    1.33 +#endif
    1.34 +	index = (hndl & HANDLESYS_HANDLE_MASK);
    1.35 +
    1.36 +	assert(index != 0 && index <= m_HandleTail && index < HANDLESYS_MAX_HANDLES);
    1.37 +
    1.38 +	pHandle = &m_Handles[index];
    1.39 +
    1.40 +	assert(pHandle->set && pHandle->set != HandleSet_Freed);
    1.41 +	assert(pHandle->serial == serial);
    1.42 +}
    1.43 +
    1.44  HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index)
    1.45  {
    1.46  	QHandleType *pType = &m_Types[pHandle->type];