Пример #1
0
void FreePidInfo(PID_INFO_PTR pid_info)
{
	PID_INFO_PTR prev_used_pid, prev_free_pid;

	assert( pid_info != NULL );
	assert( pid_info != &pid_zero );

	SpinLock( &pid_info_lock );
	prev_used_pid = STRUCT_ADDRESS_FROM_MEMBER( &pid_info->inuse_list.prev,	PID_INFO, inuse_list.prev );
	prev_free_pid = STRUCT_ADDRESS_FROM_MEMBER( &pid_info->free_list.prev,	PID_INFO, free_list.prev );

	/*transfer free pids to previous node*/
	prev_used_pid->free_count = pid_info->free_count + 1;
	if ( pid_info->free_count > 0 )
	{
		AddToList( &prev_used_pid->free_list, &pid_info->free_list );
		RemoveFromList(  &pid_info->free_list );
	}
	else
		AddToList( &prev_used_pid->free_list, &pid_zero.free_list );

	RemoveFromList(  &pid_info->inuse_list );
	RemoveNodeFromAvlTree( &pid_root, &pid_info->tree_node, 0, compare_pid_info);
	SpinUnlock( &pid_info_lock );

	FreeBuffer( pid_info, &pid_cache );
}
Пример #2
0
int RecursiveRemoveChilds(int pos,ListParam *param)
{
	ListParam localparam;
	int rootid;
	int i=0;
	int menuitemid;//id
	int objidx;//pos in array
	int *MenuItemsCount;
	PMO_IntMenuItem *MenuItems=NULL;

	objidx=GetMenuObjbyId(param->MenuObjectHandle);
	if ((objidx==-1)){return(-1);}

	localparam=*param;

	//rootid=(*param->MenuItems)[pos].id|param->cntFlag;
	rootid=getGlobalId(MenuObjects[objidx].id,MenuObjects[objidx].MenuItems[pos].id);
	menuitemid=MenuObjects[objidx].MenuItems[pos].id;

	MenuItems=&MenuObjects[objidx].MenuItems;
	MenuItemsCount=&MenuObjects[objidx].MenuItemsCount;

	if ((*MenuItems)[pos].mi.flags&CMIF_ROOTPOPUP) {
		while(i<*MenuItemsCount) {
			if ((*MenuItems)[i].mi.root!=rootid||(*MenuItems)[i].mi.root==-1) {
				i++;
				continue;
			}
			if ((*MenuItems)[i].mi.flags&CMIF_ROOTPOPUP) {
				RecursiveRemoveChilds(i,&localparam);
				i=0;
				continue;
			}
			if ((*MenuItems)[i].mi.flags&CMIF_CHILDPOPUP) {
				FreeAndNil(&((*MenuItems)[i].mi.pszName));
				FreeAndNil(&((*MenuItems)[i].CustomName));
				FreeAndNil(&((*MenuItems)[i].UniqName));
				if (MenuObjects[objidx].FreeService)
					CallService(MenuObjects[objidx].FreeService,(WPARAM)(*MenuItems)[i].globalid,(LPARAM)(*MenuItems)[i].mi.ownerdata);

				RemoveFromList(i,(void **)MenuItems,MenuItemsCount,sizeof(TMO_IntMenuItem));
				i=0;
				continue;
	}	}	}

	i = GetMenuItembyId( objidx, menuitemid );
	if ( i >= 0 && i < *MenuItemsCount ) {
		FreeAndNil(&((*MenuItems)[i].mi.pszName));
		FreeAndNil(&((*MenuItems)[i].CustomName));
		FreeAndNil(&((*MenuItems)[i].UniqName));

		if (MenuObjects[objidx].FreeService)
			CallService(MenuObjects[objidx].FreeService,(WPARAM)(*MenuItems)[i].globalid,(LPARAM)(*MenuItems)[i].mi.ownerdata);

		RemoveFromList(i,(void **)MenuItems,MenuItemsCount,sizeof(TMO_IntMenuItem));
	}
	return 0;
}
Пример #3
0
/*************************************
* Remove the first range that matches
*************************************/
int	RemoveFromList(NumList* n, unsigned int Number){
	NumItem*	i;
	int			j;
	
	DEBUGPATH;

	if (!n->NumEntries) return FALSE;
	
	for (j=0;j<n->NumEntries;j++){
		i=n->Items[j];
#ifdef DEBUG	
		printf("Checking for %u in %u-%u\n",Number, i->Lower, i->Upper);
#endif
		if (i->SubList){
			if (RemoveFromList(i->SubList, Number)) return TRUE;
		}else if ( (i->Lower<=Number) && (i->Upper>=Number) ){
			free(n->Items[j]);
			n->Items[j]=NULL;
			memmove(&n->Items[j], &n->Items[j+1], sizeof(NumItem*)*(n->NumEntries-j));
			n->Items[n->NumEntries]=NULL;
			n->NumEntries--;
			return TRUE;
		}	
	}
	
	return FALSE;
}
Пример #4
0
void RemoveFromTrack(void* p)
{
	if(gpMemoryTable != NULL)
	{
		RemoveFromList(gpMemoryTable, p);
	}
}
Пример #5
0
/////////////////////////////////////////////////////////////////////////////
// CMallocSpy::PreRealloc
//
/////////////////////////////////////////////////////////////////////////////
SIZE_T CMallocSpy::PreRealloc(void* pRequest, SIZE_T cbRequest,
                             void** ppNewRequest, BOOL fSpyed)
{
	ASSERT(pRequest && ppNewRequest);
    
	//If this was alloced under IMallocSpy we need to adjust
	//the size stored in the header
    if(fSpyed)
    {
		//Remove the original pRequest pointer from the list
		//Since Realloc could change the original pointer
		RemoveFromList(pRequest);
	
        //Find the start 
		*ppNewRequest = HEADER_OFFSET(pRequest);
		
		//Store the new desired size
		m_cbRequest = cbRequest;
		
		//Return the total size, including extra
		return (m_cbRequest + HEADERSIZE + FOOTERSIZE);
    }

	//else
	*ppNewRequest = pRequest;
    return cbRequest;
}
Пример #6
0
void CValidateAlloc::Free( void *pMem )
{
	HeapPrefix_t *pHeap	= PrefixFromAllocation( pMem );
	RemoveFromList( pHeap );

	g_pActualAlloc->Free( pHeap );
}
Пример #7
0
void GameList::DeleteItem(int index)
{
    GameElement *element = RemoveFromList(index);
    if( element != NULL ) {
        delete element;
    }
}
Пример #8
0
void  CValidateAlloc::Free( void *pMem, const char *pFileName, int nLine )
{
	HeapPrefix_t *pHeap	= PrefixFromAllocation( pMem );
	RemoveFromList( pHeap );

	g_pActualAlloc->Free( pHeap, pFileName, nLine );
}
Пример #9
0
//-----------------------------------------------------------------------------
// Purpose: Removes the face at the given index from the selection set.
// Input  : nIndex - Index of the face in the selection list.
//-----------------------------------------------------------------------------
void CToolPickFace::DeselectFace(int nIndex)
{
	ASSERT(m_Faces.IsValidIndex(nIndex));

	if (m_Faces.IsValidIndex(nIndex))
	{
		if (m_Faces[nIndex].eOriginalState != FaceState_Partial)
		{
			m_Faces[nIndex].pFace->SetSelectionState(SELECT_NONE);

			//
			// Remove the face from our list.
			//
			RemoveFromList(nIndex);
		}
		else
		{
			//
			// Just set the state to deselected so we can cycle back to partial selection.
			//
			m_Faces[nIndex].pFace->SetSelectionState(SELECT_NONE);
			m_Faces[nIndex].eState = FaceState_None;
		}
	}
}
Пример #10
0
/*! Allocate PID info structure
	\param ppid - parent process id
	\return on success - pid info structure
			on failure - null
*/
PID_INFO_PTR AllocatePidInfo(int ppid)
{
	PID_INFO_PTR pid_info, pid_free;

	pid_info = AllocateBuffer(&pid_cache, CACHE_ALLOC_SLEEP);
	if ( pid_info == NULL )
		return NULL;

	SpinLock( &pid_info_lock );
	
	pid_free = STRUCT_ADDRESS_FROM_MEMBER( pid_zero.free_list.next, PID_INFO, free_list );

	assert( pid_free != NULL );
	assert( pid_free->free_count > 0 );
	pid_free->free_count--;
	
	/*use the first available pid*/
	pid_info->pid = pid_free->pid + 1;
	pid_info->ppid = ppid;
	pid_info->free_count = pid_free->free_count;
	if ( pid_free->free_count > 0 )
		AddToList( &pid_free->free_list, &pid_info->free_list );
	RemoveFromList( &pid_free->free_list );

	/*add to the used pid list*/
	AddToList( &pid_free->inuse_list, &pid_info->inuse_list );
	/*add to the tree*/
	InsertNodeIntoAvlTree( &pid_root, &pid_info->tree_node, 0, compare_pid_info );
	SpinUnlock( &pid_info_lock );

	return pid_info;
}
Пример #11
0
void Audio::UnloadSoundEffect(const char* pszFilePath)
{
    int sound = Hash(pszFilePath);

    UnloadSoundEffect(sound);

    RemoveFromList(sound);
}
Пример #12
0
void GameObjectManager::FindCollided(GameObject* hit){
	for (std::unordered_map<uint, GameObject*>::iterator is = objects.begin(); is != objects.end(); ++is)
	{
		if (hit == is->second){
			RemoveFromList(is->first);
			break;
		}
	}
}
Пример #13
0
//-----------------------------------------------------------------------------
// Purpose: immediately stop playing this sound 
// Input  : *pSound - Patch to shut down
//-----------------------------------------------------------------------------
void CSoundControllerImp::Shutdown( CSoundPatch *pSound )
{
	if ( !pSound )
		return;

	pSound->Shutdown();
	CommandClear( pSound );
	RemoveFromList( pSound );
}
bool CPowerUp::OnCollision(CEntity* Entity) 
{    
    if ((Entity->Type == ENTITY_TYPE_PLAYER) && !Dead)
    {             
        // Kill Power-up
        Kill();
        
        //Move it away NOW
        int OldX = X;
        X = -100;
        
        CMario* player = GetPlayer();
        
        switch(PowerUpType)
        {
            case POWERUP_TYPE_GREEN: // gain 1 Life                
                CAreaScoring::AreaScoring.AddLife(1);   
                
                // Play Sound
                CSoundManager::SoundManager.Play(FX_1UP);
    
                break;
              
            case POWERUP_TYPE_RED: // become SUPER Mario
                
                if (SUPER_MARIO > player->MarioState)
                    player->ChangeMarioState(SUPER_MARIO);
                else // Store it for later
                {
                    player->ReservePowerUp = PowerUpType;
                    
                    // Play Sound
                    CSoundManager::SoundManager.Play(FX_RESERVE_STORED);
                }
                
                break;            
                
            case POWERUP_TYPE_FIREFLOWER: // become SUPER Mario 
                
                if (FIRE_MARIO > player->MarioState)
                    player->ChangeMarioState(FIRE_MARIO);

                break;                  
        }
        
        // Add Power-up value to score        
        CAreaScoring::AreaScoring.AddPoints(Points);
        
        // Display Points
        ShowPoints(Points, OldX, Y);
        
        RemoveFromList();
    }
   
    return true;
}
Пример #15
0
/*
**  Purpose:	Capture all requests to free information and also
**		remove items from the allocation list.
**  Arguments:	vp_Alloced	The memory to free.
**		cp_File		The file calling free.
**		ssi_Line	The line of cp_File calling free.
**  Return Value:	void
**  Remarks/Portability/Dependencies/Restrictions:
**		If the pointer value is invalid, then an item will be added
**		to the list and nothing else is done.
**		I really like the name of this function and one day hope
**		that Lynx is Leak Free.
**  Revision History:
**	05-26-94	created Lynx 2-3-1 Garrett Arch Blythe
*/
PUBLIC void LYLeakFree ARGS3(
	void *,		vp_Alloced,
	CONST char *,	cp_File,
	CONST short,	ssi_Line)
{
    AllocationList *ALp_free;

    if (LYfind_leaks == FALSE) {
	free(vp_Alloced);
	return;
    }

    /*
     *	Find the pointer in the allocated list.
     *	If not found, bad pointer.
     *	If found, free list item and vp_Allloced.
     */
    ALp_free = FindInList(vp_Alloced);
    if (ALp_free == NULL) {
	/*
	 *  Create the final entry before exiting marking this error.
	 *  If unable to allocate more memory just exit.
	 */
	AllocationList *ALp_new = typecalloc(AllocationList);

	if (ALp_new == NULL) {
	    exit(EXIT_FAILURE);
	}

	/*
	 *  Set up the information, no memory need be allocated
	 *  for the file name since it is a static string.
	 */
	ALp_new->vp_Alloced = NULL;
	ALp_new->vp_BadRequest = vp_Alloced;
	ALp_new->SL_memory.cp_FileName = cp_File;
	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;

	/*
	 *  Add the entry to the list and then return.
	 */
	AddToList(ALp_new);
	return;
    } else {
	/*
	 *  Free off the memory.
	 *  Take entry out of allocation list.
	 */
	CountFrees(ALp_free->st_Bytes);
	RemoveFromList(ALp_free);
	FREE(ALp_free);
	FREE(vp_Alloced);
    }
}
Пример #16
0
//--------------------------------------------------------------------------------
//      CArrayIterator::free
//--------------------------------------------------------------------------------
void
CArrayIterator::free()
{
    if (fDynamicArray) {
	fDynamicArray->fIterator = RemoveFromList();
	fDynamicArray = nil;
    }
	
    super::free();

} // CArrayIterator::free
Пример #17
0
void *CValidateAlloc::Expand( void *pMem, size_t nSize, const char *pFileName, int nLine )
{
	HeapPrefix_t *pHeap	= PrefixFromAllocation( pMem );
	RemoveFromList( pHeap );

	int nActualSize = nSize + sizeof(HeapPrefix_t) + sizeof(HeapSuffix_t);
	pHeap = (HeapPrefix_t*)g_pActualAlloc->Expand( pHeap, nActualSize, pFileName, nLine );
	AddToList( pHeap, nSize );

	return AllocationStart( pHeap );
}
Пример #18
0
void *CValidateAlloc::Realloc( void *pMem, size_t nSize )
{
	HeapPrefix_t *pHeap	= PrefixFromAllocation( pMem );
	RemoveFromList( pHeap );

	int nActualSize = nSize + sizeof(HeapPrefix_t) + sizeof(HeapSuffix_t);
	pHeap = (HeapPrefix_t*)g_pActualAlloc->Realloc( pHeap, nActualSize );
	AddToList( pHeap, nSize );

	return AllocationStart( pHeap );
}
Пример #19
0
void Audio::StopBackgroundMusic(bool bReleaseData)
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    StopSoundEffect(m_backgroundID);

    if (bReleaseData){
        UnloadSoundEffect(m_backgroundID);
        RemoveFromList(m_backgroundID);
    }
}
Пример #20
0
CNodeList::Node::~Node()
{
   try
   {
      RemoveFromList();
   }
   catch(...)
   {
   }

   m_pNext = 0;
   m_pPrev = 0;
   m_pList = 0;
}
Пример #21
0
//--------------------------------------------------------------------------------
//      CArrayIterator::SwitchArray
//--------------------------------------------------------------------------------
void CArrayIterator::SwitchArray(CDynamicArray* newArray, Boolean itsForward)
{
    // switch from one array to another
    XASSERT(newArray);

    if (fDynamicArray)
	{
	fDynamicArray->fIterator = RemoveFromList();
	fDynamicArray = nil;
	}

    init(newArray, 0, newArray->fSize - 1, itsForward);

} // CArrayIterator::SwitchArray
Пример #22
0
void DetachNode(Node *theNode) {

	Node *theParent;

	if(!theNode) return;

	if (theNode == NULL) return;
	theParent = theNode->parent;
	if (theParent == NULL) return; // already detached (or root node)
	theNode->parent = NULL;
	RemoveFromList(theParent->nodeChilds, theNode);
	// Update bounding box of parent
	nodePropagateBBRoot(theParent);

}
Пример #23
0
	template <class T> void DoUnAssociate(T &map, unsigned long id)
	{
		/* For each occurence of 'id' (well, only one..it's not a multimap) in 'map'
		 * remove it from the map, take an Extensible* value from the map and remove
		 * 'id' from the list of query IDs attached to it.
		 */
		typename T::iterator iter = map.find(id);

		if(iter != map.end())
		{
			/* Found a value indexed by 'id', call RemoveFromList()
			 * on it with 'id' to remove 'id' from the list attached
			 * to the value.
			 */
			RemoveFromList(iter->second, id);
		}
	}
Пример #24
0
//wparam=MenuObjectHandle
int MO_RemoveMenuObject(WPARAM wParam,LPARAM lParam)
{
	int objidx;

	if (!isGenMenuInited) return -1;
	lockmo();


	objidx=GetMenuObjbyId((int)wParam);
	if (objidx==-1){unlockmo();return(-1);}

	RemoveAndClearOneObject(objidx);

	RemoveFromList(objidx,&MenuObjects,&MenuObjectsCount,sizeof(MenuObjects[objidx]));
	unlockmo();
	return(0);
}
Пример #25
0
void CAudioPolicy::MakeRequest(CMMFAudioPolicyRequest* aAudioPolicyRequest)
	{
// since we have a FIFO q, then remove request and re-add it.
	RemoveFromList(aAudioPolicyRequest->PolicySessionId(), EFalse); 
	if (iStopHandledFromSessId==aAudioPolicyRequest->PolicySessionId())
		{
		iStopHandledFromSessId=KErrNotFound;
		}
// Process Request by looking at priorities, preferences, special states...
	TPolicyResponse responseValue = ProcessRequest(aAudioPolicyRequest);
#if defined(ALLOW_POLICY_DEBUG)
	RDebug::Print(_L("Sess ID=%d, Priority=%d"),aAudioPolicyRequest->PolicySessionId(),aAudioPolicyRequest->Priority());
#endif	
	switch (responseValue)
		{
		case EDenied:
			{
			TMMFAudioPolicyEvent responseEvent(TMMFAudioPolicyEvent::EMMFAudioPolicyPriorityTooLow, KErrInUse,EMMFStateWaitingForResource);
			// the client won't be notified until he has request so, so we can set its state anyway
			aAudioPolicyRequest->SetState( EMMFStateWaitingForResource ); 
			iAudioPolicyServer->SendEventToClient(aAudioPolicyRequest->PolicySessionId(), responseEvent);
			}
			break;
		case EProceed:
			{
			iAudioPolicyServer->StopNotificationTimer();
			TMMFAudioPolicyEvent responseEvent(TMMFAudioPolicyEvent::EMMFAudioPolicyNoEvent, KErrNone, aAudioPolicyRequest->State());
			iAudioPolicyServer->SendEventToClient(aAudioPolicyRequest->PolicySessionId(), responseEvent);
			}
			break;
		case EStopThenProceed:
			{
			iAudioPolicyServer->StopNotificationTimer(); 
			iSessionIdAwaitingForDevsound=aAudioPolicyRequest->PolicySessionId();
			// we have to wait for devsound to stop client(s), then notify that one
			}
			break;
		case EResume:
		case EMix:
		default:
			ASSERT(EFalse);
		}
	TRAPD(err, iAudioPolicyRequestArray->AppendL(aAudioPolicyRequest) );
	__ASSERT_ALWAYS(err==KErrNone, Panic(EMMFAudioPolicyRequestArrayOverflow) ); // we reserved space, so shouldn't hit this
	}
Пример #26
0
void BlockBufferAllocator::ForEach(BlockBufferProcessFunc func, void * userData)
{
	MemBufferBlock * block = _listHead;
	while(block != 0)
	{

		func(block, userData);
		MemBufferBlock * nextBlock = block->_next;

		if (block->IsFull())
		{
			RemoveFromList(block);
			FreeMemBufferBlock(block);
		}

		block = nextBlock;
	}
}
Пример #27
0
void Ydb_DeadlockTree::Remove(Ydb_Trans* trans) {
  DeadlockTable::iterator iter = blocks_.find(trans);
  if (iter == blocks_.end()) {
    return;
  }

  // Remove this transaction from the list of blocked by transactions for each
  // transaction waiting on it.
  TransList* translist = iter->second;
  for (TransList::iterator trans_iter = translist->begin();
       trans_iter != translist->end(); ++trans_iter) {
    DeadlockTable::iterator blocked_iter = blocked_by_.find(*trans_iter);
    assert(blocked_iter != blocked_by_.end());
    TransList* list = blocked_iter->second;
    RemoveFromList(list, trans);
  }
  blocks_.erase(iter);
  delete translist;
}
Пример #28
0
/////////////////////////////////////////////////////////////////////////////
// void* CMallocSpy::PreFree
//
/////////////////////////////////////////////////////////////////////////////
void* CMallocSpy::PreFree(void* pRequest, BOOL fSpyed)
{
	//pRequest is the users pointer to thier buffer, not the header

	//E_OUTOFMEMORY condition
	if(!pRequest)
		return NULL;

    //If this memory was alloced under IMallocSpy, need to remove it
    if(fSpyed)
	{
		//Remove this pointer from the list
		RemoveFromList(pRequest);
	
		void* pActual	= HEADER_OFFSET(pRequest);
		ULONG ulID		= BUFFER_ID(pActual);
		
		//Make sure that the head/tail signitures are intact
		if(HEAD_SIGNITURE(pActual) != HEADSIGN)
			InternalTraceFmt(L"TRACE - IMallocSpy HeadSigniture Corrupted! - 0x%p, ID=%08lu, %Iu byte(s)\n", pRequest, ulID, BUFFER_LENGTH(pActual));

		if(TAIL_SIGNITURE(pActual) != TAILSIGN)
			InternalTraceFmt(L"TRACE - IMallocSpy TailSigniture Corrupted! - 0x%p, ID=%08lu, %Iu byte(s)\n", pRequest, ulID, BUFFER_LENGTH(pActual));

		//Break at indicated Allocation
		if(g_dwBreakID == ulID)
			BREAKINTO();

		//Set the UsersBuffer to a known char
		memset(pRequest, FREESIGN, BUFFER_LENGTH(pActual));

		//Need to return the actual header pointer to
		//free the entire buffer including the heading
		return pActual;
	}

	//else
	return pRequest;
}
Пример #29
0
int ProcessDHCPIAPD(struct dhcp6_prefix  *pstPrefix, int iSet)
{
    DHCP6C_INFO_LIST stPrefix;

    if (!pstPrefix)
    {
        loginfo(FUNC, "args NULL");
        return (-1);
    }

    loginfo(FUNC, "Now, begin to process dhcp iapd ......\r\n\r\n");

    /* 增加节点 */
    if (iSet)
    {
        // TODO: 目前来说,如果一个IA带有多个前缀,那么WAN侧也只要一个前缀
        // TODO: 后续如果要支持多个前缀的话,那么需要将本函数提到update_prefix函数的上一层也就是update_ia
        if (NULL == FindNodeByType(en_type_iapd, (void *)pstPrefix))
        {
            loginfo(FUNC, "add prefix:["NIP6_FMT"]", NIP6(pstPrefix->addr));
            ClearDHCP6CInfoList(en_type_iapd);
            AddIntoList(en_type_iapd, (void *)pstPrefix);
            SetFlagByType(en_type_iapd, en_changed);
        }
    }
    else
    {
        loginfo(FUNC, "Remove iapd" NIP6_FMT " from iapd list...\r\n\r\n", NIP6(pstPrefix->addr));
        if (0 == RemoveFromList(en_type_iapd, (void *)pstPrefix))
        {
            SetFlagByType(en_type_iapd, en_changed);
        }
    }

    loginfo(FUNC, "process dhcp iapd over........\r\n\r\n\r\n");

    return (0);
}
Пример #30
0
/**
 * Remove handler from list and dispose of memory
 */
static void
dispose_handler(handler *h)
{
	RemoveFromList(dbg_handlers, (void *)h);
	free(h);
}