示例#1
0
文件: mlock.c 项目: Yurand/tw-light
void _mac_lock(void * address,unsigned long size)
{
   static first=1;
   lock_mem * temp;
   if(first)
      atexit(mac_unlock_all);
   first=0;
   
   for(temp = top;temp != NULL;temp=temp->next){
      if(address == temp->address){
         if(size == temp->size){
	    temp->count++;
	 }
	 else{
	    UnholdMemory(temp->address,temp->size);
	    HoldMemory(address,size);
	    temp->address=address;
	    temp->size=size;
	    temp->count=1;
	 }
         return;
      }
   }
   temp=(lock_mem *)NewPtr(sizeof(lock_mem));
   if(temp){
      temp->address=address;
      temp->size=size;
      temp->count=1;
      temp->next=top;
      top=temp;
   }
   HoldMemory(address,size);
}
示例#2
0
static void lockMemory( INOUT MEM_INFO_HEADER *memHdrPtr )
	{
	assert( isWritePtr( memHdrPtr, sizeof( MEM_INFO_HEADER ) ) );

#if !defined( CALL_NOT_IN_CARBON ) || CALL_NOT_IN_CARBON
	if( HoldMemory( memPtr, memHdrPtr->size ) == noErr )
		memHdrPtr->flags |= MEM_FLAG_LOCKED;
#endif /* Non Mac OS X memory locking */
	}