kernel/eka/memmodel/epoc/flexible/mmu/mvalloc.cpp
changeset 149 d9f1e5bfe28c
parent 0 a41df078684a
equal deleted inserted replaced
135:5e441a173c63 149:d9f1e5bfe28c
   686 	}
   686 	}
   687 
   687 
   688 
   688 
   689 RVirtualAllocSlabSet* RVirtualAllocSlabSet::New(RVirtualAllocator* aAllocator, TUint aNumSlabTypes, DMutex*& aWriteLock)
   689 RVirtualAllocSlabSet* RVirtualAllocSlabSet::New(RVirtualAllocator* aAllocator, TUint aNumSlabTypes, DMutex*& aWriteLock)
   690 	{
   690 	{
   691 	TUint size = sizeof(RVirtualAllocSlabSet)+sizeof(((RVirtualAllocSlabSet*)0x100)->iSlabs)*(aNumSlabTypes-1);
   691 	TUint size = sizeof(RVirtualAllocSlabSet) + sizeof(SDblQue) * (aNumSlabTypes - 1);
   692 	RVirtualAllocSlabSet* set = (RVirtualAllocSlabSet*)Kern::AllocZ(size);
   692 	RVirtualAllocSlabSet* set = (RVirtualAllocSlabSet*)Kern::AllocZ(size);
   693 	if(set)
   693 	if(set)
   694 		new (set) RVirtualAllocSlabSet(aAllocator,aNumSlabTypes,aWriteLock);
   694 		new (set) RVirtualAllocSlabSet(aAllocator,aNumSlabTypes,aWriteLock);
   695 	return set;
   695 	return set;
   696 	}
   696 	}
   762 			}
   762 			}
   763 		TVirtualSlab* slab = NewSlab(0,aSlabType);
   763 		TVirtualSlab* slab = NewSlab(0,aSlabType);
   764 		if(!slab)
   764 		if(!slab)
   765 			return KErrNoMemory;
   765 			return KErrNoMemory;
   766 		TLinAddr addr = slab->Alloc(aSizeShift);
   766 		TLinAddr addr = slab->Alloc(aSizeShift);
   767 		if(!addr)
   767 		// Shouldn't ever fail as we've just allocated an empty slab and we can't 
   768 			return KErrNoMemory;
   768 		// attempt to allocate more than a whole slab.
       
   769 		__NK_ASSERT_DEBUG(addr);
   769 		aAddr = addr;
   770 		aAddr = addr;
   770 		return KErrNone;
   771 		return KErrNone;
   771 		}
   772 		}
   772 
   773 
   773 	TVirtualSlab* slab = (TVirtualSlab*)iSlabs.Find(aAddr&~KVirtualAllocSlabMask);
   774 	TVirtualSlab* slab = (TVirtualSlab*)iSlabs.Find(aAddr&~KVirtualAllocSlabMask);
   828 
   829 
   829 
   830 
   830 RVirtualAllocator::~RVirtualAllocator()
   831 RVirtualAllocator::~RVirtualAllocator()
   831 	{
   832 	{
   832 	__NK_ASSERT_DEBUG(iAllocator==0 || iAllocator->iAvail==iAllocator->iSize); // should be empty
   833 	__NK_ASSERT_DEBUG(iAllocator==0 || iAllocator->iAvail==iAllocator->iSize); // should be empty
   833 	Kern::Free(iAllocator);
   834 	delete iAllocator;
   834 	Kern::Free(iSlabSet);
   835 	delete iSlabSet;
   835 	}
   836 	}
   836 
   837 
   837 
   838 
   838 TInt RVirtualAllocator::Construct(TLinAddr aStart, TLinAddr aEnd, TUint aNumSlabTypes, DMutex*& aWriteLock)
   839 TInt RVirtualAllocator::Construct(TLinAddr aStart, TLinAddr aEnd, TUint aNumSlabTypes, DMutex*& aWriteLock)
   839 	{
   840 	{