persistentstorage/dbms/ustor/US_CLSTR.CPP
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "US_STD.H"
       
    17 
       
    18 // Class RClusterMap
       
    19 
       
    20 void RClusterMap::InsertL( TClusterId aCluster, TClusterId aPrevious )
       
    21 //
       
    22 // insert the entry into the map
       
    23 //
       
    24 	{
       
    25 	TIdPair* map = iMap;
       
    26 	if ( iEntries == iAlloc )
       
    27 		{	// ensure there is space
       
    28 		TInt size = iAlloc + EGranularity;
       
    29 		iMap = map = ( TIdPair* )User::ReAllocL( map, size * sizeof( TIdPair ) );
       
    30 		iAlloc = size;
       
    31 		}
       
    32 	TInt l = 0;
       
    33 	TInt r = iEntries;
       
    34 	while ( r > l )
       
    35 		{
       
    36 		TInt m = ( l + r ) >> 1;
       
    37 		TClusterId id = map[ m ].iId;
       
    38 		__ASSERT( aCluster != id );	// not already present
       
    39 		if ( aCluster < id )
       
    40 			r = m;
       
    41 		else
       
    42 			l = m + 1;
       
    43 		}
       
    44 	TIdPair* p = map + r;
       
    45 	TIdPair* e = map + iEntries++;
       
    46 	Mem::Move( p + 1, p, ( TUint8* )e - ( TUint8* )p );
       
    47 	p->iId = aCluster;
       
    48 	p->iPreviousId = aPrevious;
       
    49 	}
       
    50 
       
    51 RClusterMap::TIdPair* RClusterMap::At( TClusterId aCluster )
       
    52 	{
       
    53 	TInt l = 0;
       
    54 	TInt r = iEntries;
       
    55 	while ( r > l )
       
    56 		{
       
    57 		TInt m = ( l + r ) >> 1;
       
    58 		TClusterId id = iMap[ m ].iId;
       
    59 		if ( aCluster < id )
       
    60 			r = m;
       
    61 		else if ( aCluster > id )
       
    62 			l = m + 1;
       
    63 		else
       
    64 			return iMap + m;
       
    65 		}
       
    66 	return 0;
       
    67 	}
       
    68 
       
    69 void RClusterMap::ResetL( TClusterId aHeadCluster )
       
    70 	{
       
    71 	iComplete = EFalse;
       
    72 	iEntries = 0;
       
    73 	InsertL( aHeadCluster, KNullClusterId );
       
    74 	iLastMapped = iLastBound = aHeadCluster;
       
    75 	iSkipped = ESeparation - 1;
       
    76 	}
       
    77 
       
    78 TBool RClusterMap::At( TClusterId aCluster, TClusterId& aPreviousCluster )
       
    79 	{
       
    80 	TIdPair* p = At( aCluster );
       
    81 	if ( p )
       
    82 		aPreviousCluster = p->iPreviousId;
       
    83 	else if ( aCluster == iLastBound )
       
    84 		aPreviousCluster = iLastMapped;
       
    85 	else
       
    86 		return EFalse;
       
    87 	return ETrue;
       
    88 	}
       
    89 
       
    90 void RClusterMap::AddL( TClusterId aCluster )
       
    91 	{
       
    92 	__ASSERT( aCluster != KNullClusterId );
       
    93 	if ( --iSkipped < 0 )
       
    94 		{
       
    95 		InsertL( aCluster, iLastMapped );
       
    96 		iLastMapped = aCluster;
       
    97 		iSkipped = ESeparation - 1;
       
    98 		}
       
    99 	iLastBound = aCluster;
       
   100 	}
       
   101 
       
   102 void RClusterMap::DropL( TClusterId aCluster, TClusterId aNext )
       
   103 //
       
   104 // Cluster has been deleted, modify entry to contain the next cluster
       
   105 // last cluster in table is never deleted
       
   106 //
       
   107 	{
       
   108 	if ( aCluster == iLastBound )
       
   109 		iLastBound = aNext;
       
   110 	TIdPair* entry = At( aCluster );
       
   111 	if ( !entry )
       
   112 		return;		// not in the sparse map
       
   113 // remove entry for cluster->prev
       
   114 	TClusterId prev = entry->iPreviousId;
       
   115 	Mem::Move( entry, entry + 1, ( TUint8* )( iMap + --iEntries ) - ( TUint8* )entry );
       
   116 //
       
   117 	if ( aCluster == iLastMapped )
       
   118 		iLastMapped = aNext;
       
   119 	else
       
   120 		{	// find the referring entry next->cluster
       
   121 		TIdPair* pnext = iMap;
       
   122 		while ( pnext->iPreviousId != aCluster )
       
   123 			{
       
   124 			++pnext;
       
   125 			__ASSERT( pnext < iMap + iEntries );
       
   126 			}
       
   127 		if ( pnext->iId == aNext )
       
   128 			{	// referring entry is the next one => drop a link
       
   129 			pnext->iPreviousId = prev;
       
   130 			return;
       
   131 			}
       
   132 		// adjust next->new
       
   133 		pnext->iPreviousId = aNext;
       
   134 		}
       
   135 	// add in new link to replace deleted one
       
   136 	InsertL( aNext, prev );	// will not fail allocation as space available
       
   137 	}
       
   138 
       
   139 // Class TClusterLinkCache
       
   140 
       
   141 void TClusterLinkCache::Add( TClusterId aCluster, RClusterMap& aMap )
       
   142 //
       
   143 // Add an entry to the cache
       
   144 //
       
   145 	{
       
   146 	__ASSERT( iEnd != NULL );
       
   147 	TClusterId id;
       
   148 	__ASSERT( aMap.At( iMap[0], id ) );
       
   149 //
       
   150 	TClusterId* p = iEnd;
       
   151 	if ( p == &iMap[ RClusterMap::ESeparation ] )
       
   152 		{	// full, requires a shift down
       
   153 		for ( ; !aMap.At( *p, id ); --p )
       
   154 			{
       
   155 			__ASSERT( p > iMap );
       
   156 			}
       
   157 		__ASSERT( p > iMap );
       
   158 		__ASSERT( Has( id ) );
       
   159 
       
   160 		TClusterId* c = iMap;
       
   161 		--c;
       
   162 		while ( p <= iEnd )
       
   163 			*++c = *p++;
       
   164 		p = c;
       
   165 		}
       
   166 	*++p = aCluster;
       
   167 	iEnd = p;
       
   168 	}
       
   169 
       
   170 void TClusterLinkCache::Add( const TClusterId* aFirst, const TClusterId* aLast )
       
   171 //
       
   172 // Add several linked TClusterIds
       
   173 //
       
   174 	{
       
   175 	__ASSERT( iEnd != NULL );
       
   176 //
       
   177 	TClusterId* p = iEnd;
       
   178 	while ( aFirst < aLast && p < &iMap[ RClusterMap::ESeparation ] )
       
   179 		*++p = *aFirst++;
       
   180 	iEnd = p;
       
   181 	}
       
   182 
       
   183 void TClusterLinkCache::Drop( TClusterId aCluster, TClusterId aNext )
       
   184 //
       
   185 // Drop the item if it is in the cache
       
   186 //
       
   187 	{
       
   188 	TClusterId* p = iEnd;
       
   189 	if ( !p )
       
   190 		return;
       
   191 	if ( *p == aCluster )
       
   192 		{
       
   193 		*p = aNext;
       
   194 		return;
       
   195 		}
       
   196 	do
       
   197 		{
       
   198 		if ( p == iMap )
       
   199 			return;
       
   200 		} while ( *--p != aCluster );
       
   201 	__ASSERT( *( p + 1 ) == aNext );
       
   202 	for ( ; p < iEnd; ++p )
       
   203 		*p = *( p + 1 );
       
   204 	iEnd = p - 1;
       
   205 	}
       
   206 
       
   207 TBool TClusterLinkCache::Has( TClusterId aCluster ) const
       
   208 //
       
   209 // Check if the cluster id is in the cache
       
   210 // iEnd==0 is a valid state (empty cache)
       
   211 //
       
   212 	{
       
   213 	for ( const TClusterId* p = iEnd; p >= iMap; )
       
   214 		{
       
   215 		if ( *p-- == aCluster )
       
   216 			return ETrue;
       
   217 		}
       
   218 	return EFalse;
       
   219 	}
       
   220 
       
   221 TBool TClusterLinkCache::At( TClusterId aCluster, TClusterId& aPrevious ) const
       
   222 //
       
   223 // If aCluster is in the cache, return the previous cluster in aPrevious
       
   224 // iEnd==0 is a valid state (empty cache)
       
   225 //
       
   226 	{
       
   227 	for ( const TClusterId* p = iEnd; p > iMap; )
       
   228 		{
       
   229 		if ( *p-- == aCluster )
       
   230 			{
       
   231 			aPrevious = *p;
       
   232 			return ETrue;
       
   233 			}
       
   234 		}
       
   235 	return EFalse;
       
   236 	}
       
   237 
       
   238 // Class TClusterDes
       
   239 
       
   240 void TClusterDes::InternalizeL(RReadStream& aStream)
       
   241 	{
       
   242 	aStream>>iNext;
       
   243 	iMembership=aStream.ReadUint16L();
       
   244 	}
       
   245 
       
   246 void TClusterDes::ExternalizeL(RWriteStream& aStream) const
       
   247 	{
       
   248 	aStream<<iNext;
       
   249 	aStream.WriteUint16L(iMembership);
       
   250 	}
       
   251 
       
   252 
       
   253 // Class CClusterCache
       
   254 
       
   255 inline CClusterCache::CClusterCache(CDbStoreDatabase& aDatabase)
       
   256 	: iDatabase(aDatabase),iCache(_FOFF(CCluster,iLink))
       
   257 	{}
       
   258 
       
   259 CClusterCache* CClusterCache::NewL(CDbStoreDatabase& aDatabase)
       
   260 	{
       
   261 	CClusterCache* self=new(ELeave) CClusterCache(aDatabase);
       
   262 	CleanupStack::PushL(self);
       
   263 	// Add the initial clusters
       
   264 	for(TInt i=0;i<(EMaxClusters/2);++i)
       
   265 		{
       
   266 		self->AddClusterL();
       
   267 		}
       
   268 	CleanupStack::Pop();
       
   269 	return self;
       
   270 	}
       
   271 
       
   272 LOCAL_C void DeleteCluster(CCluster* aCluster)
       
   273 //
       
   274 // helper function which matches the Apply() prototype
       
   275 //
       
   276 	{
       
   277 	delete aCluster;
       
   278 	}
       
   279 
       
   280 CClusterCache::~CClusterCache()
       
   281 	{
       
   282 	Apply(DeleteCluster);
       
   283 	}
       
   284 
       
   285 LOCAL_C void DiscardCluster(CCluster* aCluster)
       
   286 //
       
   287 // helper function which matches the Apply() prototype
       
   288 //
       
   289 	{
       
   290 	aCluster->Discard();
       
   291 	}
       
   292 
       
   293 void CClusterCache::Discard()
       
   294 //
       
   295 // discard the current changes in all clusters
       
   296 //
       
   297 	{
       
   298 	Apply(DiscardCluster);
       
   299 	}
       
   300 
       
   301 LOCAL_C void FlushClusterL(CCluster* aCluster)
       
   302 //
       
   303 // helper function which matches the Apply() prototype
       
   304 //
       
   305 	{
       
   306 	aCluster->FlushL();
       
   307 	}
       
   308 
       
   309 void CClusterCache::FlushL()
       
   310 //
       
   311 // Flush all the clusters in the cache
       
   312 //
       
   313 	{
       
   314 	Apply(FlushClusterL);
       
   315 	}
       
   316 
       
   317 CCluster* CClusterCache::Cluster(TClusterId aCluster)
       
   318 //
       
   319 // Look for a cluster in the cache
       
   320 //
       
   321 	{
       
   322 	TDblQueIter<CCluster> iter(iCache);
       
   323 	for (CCluster* cluster;(cluster=iter++)!=0;)
       
   324 		{
       
   325 		if (cluster->Id()==aCluster)
       
   326 			return cluster;
       
   327 		}
       
   328 	return 0;
       
   329 	}
       
   330 
       
   331 CCluster& CClusterCache::ClusterL(TClusterId aCluster)
       
   332 //
       
   333 // Get a cluster from the cache or store and move it to the top of the cache
       
   334 // Track hits to the two clusters which most recently dropped out of the cache
       
   335 //
       
   336 	{
       
   337 	CCluster* cluster=Cluster(aCluster);	// check if it is cached
       
   338 	iFollowOnHits<<=2;
       
   339 	if (!cluster)
       
   340 		{		// get an empty cluster and read it
       
   341 		if (aCluster==iCachePlus1)
       
   342 			{	// the cluster has recently been discarded
       
   343 			iCachePlus1=iCachePlus2;	// re-sequence the cache follow-on
       
   344 			iFollowOnHits|=0x1;
       
   345 			}
       
   346 		else if (aCluster==iCachePlus2)
       
   347 			iFollowOnHits|=0x2;	// the cluster has recently been discarded
       
   348 		cluster=&NewClusterL();
       
   349 		cluster->ReadL(aCluster);
       
   350 		}
       
   351 	return Touch(*cluster);
       
   352 	}
       
   353 
       
   354 CCluster& CClusterCache::ClusterL()
       
   355 //
       
   356 // Get a new (empty) cluster from the cache and move it to the top
       
   357 //
       
   358 	{
       
   359 	return Touch(NewClusterL());
       
   360 	}
       
   361 
       
   362 CCluster& CClusterCache::Touch(CCluster& aCluster)
       
   363 //
       
   364 // Move a cluster to the top of the LRU list
       
   365 //
       
   366 	{
       
   367 	aCluster.iLink.Deque();
       
   368 	iCache.AddFirst(aCluster);
       
   369 	return aCluster;
       
   370 	}
       
   371 
       
   372 CCluster& CClusterCache::AddClusterL()
       
   373 //
       
   374 // Add a new cluster to the cache
       
   375 //
       
   376 	{
       
   377 	__ASSERT(iClusters<EMaxClusters);
       
   378 	CCluster& cluster=*CCluster::NewL(Database());
       
   379 	iCache.AddLast(cluster);
       
   380 	++iClusters;
       
   381 	// move +2 hits into +1 zone and clear +1 hits
       
   382 	iFollowOnHits=TUint8((TUint(iFollowOnHits)>>1)&0x55);
       
   383 	return cluster;
       
   384 	}
       
   385 
       
   386 CCluster& CClusterCache::NewClusterL()
       
   387 //
       
   388 // Get an empty cluster from the cache, but do not touch it
       
   389 // If the hit detector has registered enough near-misses the cache is expanded
       
   390 // by adding another cluster object
       
   391 //
       
   392 	{
       
   393 	CCluster* cluster=Cluster(KNullClusterId);	// look for a discarded cluster first
       
   394 	if (cluster)
       
   395 		return *cluster;
       
   396 // check for cache expansion
       
   397 	TUint detected=iFollowOnHits;
       
   398 	if ((detected&(detected-1))!=0 && iClusters<EMaxClusters)
       
   399 		return AddClusterL();
       
   400 // retire the last cache entry
       
   401 	cluster=iCache.Last();
       
   402 	cluster->FlushL();
       
   403 	iCachePlus2=iCachePlus1;
       
   404 	iCachePlus1=cluster->Id();
       
   405 	return *cluster;
       
   406 	}
       
   407 
       
   408 void CClusterCache::Apply(void (*aFunc)(CCluster*))
       
   409 //
       
   410 // Apply the function paramater to all clusters in the cache
       
   411 // This function may leave <==> the parameter function may leave
       
   412 //
       
   413 	{
       
   414 	TDblQueIter<CCluster> iter(iCache);
       
   415 	for (CCluster* cluster;(cluster=iter++)!=0;)
       
   416 		aFunc(cluster);
       
   417 	}
       
   418 
       
   419 // Class CCluster
       
   420 
       
   421 CCluster* CCluster::NewL(CDbStoreDatabase& aDatabase)
       
   422 	{
       
   423 	return new(ELeave) CCluster(aDatabase);
       
   424 	}
       
   425 
       
   426 CCluster::~CCluster()
       
   427 	{
       
   428 	User::Free(iMap[0]);
       
   429 	}
       
   430 
       
   431 void CCluster::AdjustMap(TUint8** aMapEntry,TInt aAdjust)
       
   432 //
       
   433 // Adjust all map entries after aMapEntry
       
   434 //
       
   435 	{
       
   436 	do *aMapEntry+=aAdjust; while (++aMapEntry<=&iMap[KMaxClustering]);
       
   437 	}
       
   438 
       
   439 TInt CCluster::SetSizeL(TInt aSize)
       
   440 //
       
   441 // Set the minimum size for the cluster buffer
       
   442 // Return the offset between the new and old cells
       
   443 //
       
   444 	{
       
   445 	if (iSize>=aSize)
       
   446 		return 0;
       
   447 //
       
   448 	aSize+=EGranularity-1;		// round to granularity
       
   449 	aSize&=~(EGranularity-1);
       
   450 	TUint8* base=iMap[0];
       
   451 	TInt offset=(TUint8*)User::ReAllocL(base,aSize)-base;
       
   452 	iSize=aSize;
       
   453 	if (offset)
       
   454 		AdjustMap(&iMap[0],offset);
       
   455 	return offset;
       
   456 	}
       
   457 
       
   458 void CCluster::Discard()
       
   459 //
       
   460 // discard the current changes
       
   461 //
       
   462 	{
       
   463 	iCluster=KNullClusterId;
       
   464 	iModified=EFalse;
       
   465 	}
       
   466 
       
   467 void CCluster::Create(TClusterId aClusterId)
       
   468 //
       
   469 // Create a new cluster
       
   470 //
       
   471 	{
       
   472 	__ASSERT(!iModified);
       
   473 //
       
   474 	iCluster=aClusterId;
       
   475 	iDes.iNext=KNullClusterId;
       
   476 	iDes.iMembership=0;
       
   477 	TUint8* base=iMap[0];
       
   478 	for (TUint8** ptr=&iMap[1];ptr<=&iMap[KMaxClustering];++ptr)
       
   479 		*ptr=base;
       
   480 	iModified=ETrue;
       
   481 	}
       
   482 
       
   483 void CCluster::Relink(TClusterId aNextClusterId)
       
   484 //
       
   485 // Update the cluster to link to a different cluster
       
   486 //
       
   487 	{
       
   488 	iDes.iNext=aNextClusterId;
       
   489 	iModified=ETrue;
       
   490 	}
       
   491 
       
   492 void CCluster::AlterL(MAlter& aAlterer)
       
   493 //
       
   494 // alter all records in the cluster
       
   495 //
       
   496 	{
       
   497 	TUint members=iDes.iMembership;
       
   498 	TUint8* wptr=iMap[0];
       
   499 	TUint8* rptr=wptr;
       
   500 	for (TUint8** map=&iMap[0];map<&iMap[KMaxClustering];members>>=1,++map)
       
   501 		{
       
   502 		if (members&1)
       
   503 			{
       
   504 			TInt size=map[1]-rptr;
       
   505 			TInt expand=wptr-rptr+aAlterer.RecordExpansion(rptr,size);
       
   506 			if (expand>0)
       
   507 				{	// requires more space for alteration
       
   508 				AdjustL(map,expand+EExpandBuffer,rptr);
       
   509 				wptr=map[0];	// compensate for possible moving cache
       
   510 				rptr=map[1]-size;	// record data is at end of this entry
       
   511 				}
       
   512 			wptr=aAlterer.AlterRecordL(wptr,rptr,size);
       
   513 			rptr+=size;
       
   514 			__ASSERT(wptr<=rptr);
       
   515 			}
       
   516 		else
       
   517 			{
       
   518 			__ASSERT(map[1]==rptr);
       
   519 			}
       
   520 		map[1]=wptr;
       
   521 		}
       
   522 	iModified=ETrue;
       
   523 	}
       
   524 
       
   525 TPtrC8 CCluster::RecordL(TInt aIndex)
       
   526 //
       
   527 // Read the cluster and return the record data
       
   528 //
       
   529 	{
       
   530 	if (!((iDes.iMembership>>aIndex)&1))
       
   531 		__LEAVE(KErrNotFound);
       
   532 	return TPtrC8(iMap[aIndex],iMap[aIndex+1]-iMap[aIndex]);
       
   533 	}
       
   534 
       
   535 TUint8* CCluster::UpdateL(TInt aIndex,TInt aNewSize)
       
   536 //
       
   537 // read the cluster and return a writable descriptor over the new record data
       
   538 //
       
   539 	{
       
   540 	SetRecordL(aIndex,aNewSize);
       
   541 	iDes.iMembership|=(1<<aIndex);
       
   542 	return iMap[aIndex];
       
   543 	}
       
   544 
       
   545 TBool CCluster::DeleteL(TInt aIndex)
       
   546 //
       
   547 // return whether the cluster is empty or not
       
   548 //
       
   549 	{
       
   550 	SetRecordL(aIndex,0);
       
   551 	iDes.iMembership&=~(1<<aIndex);
       
   552 	return iDes.iMembership;
       
   553 	}
       
   554 
       
   555 void CCluster::FlushL()
       
   556 	{
       
   557 	if (iModified)
       
   558 		{	// Externalize the cluster
       
   559 		RDbStoreWriteStream cluster(iDatabase);
       
   560 		cluster.ReplaceLC(iDatabase.Store(),iCluster);
       
   561 		cluster<<iDes;
       
   562 		TUint8** map=&iMap[0];
       
   563 		TUint8* base=*map;
       
   564 		TUint8* ptr=base;
       
   565 		for (TUint members=iDes.iMembership;members!=0;members>>=1)
       
   566 			{
       
   567 			++map;
       
   568 			if (members&1)
       
   569 				{
       
   570 				TUint8* end=*map;
       
   571 				cluster << TCardinality(end-ptr);
       
   572 				ptr=end;
       
   573 				}
       
   574 			else
       
   575 				{
       
   576 				__ASSERT(*map==ptr);
       
   577 				}
       
   578 			}
       
   579 		cluster.FilterL(cluster.EMixed,iCluster);
       
   580 		cluster.WriteL(base,ptr-base);
       
   581 		cluster.CommitL();
       
   582 		CleanupStack::PopAndDestroy();
       
   583 		iModified=EFalse;
       
   584 		}
       
   585 	}
       
   586 
       
   587 void CCluster::ReadL(TClusterId aCluster)
       
   588 //
       
   589 // Internalize the cluster
       
   590 //
       
   591 	{
       
   592 	__ASSERT(iCluster!=aCluster);
       
   593 	__ASSERT(!iModified);
       
   594 //
       
   595 	iCluster=KNullClusterId;
       
   596 	RDbStoreReadStream cluster(iDatabase);
       
   597 	cluster.OpenLC(iDatabase.Store(),aCluster);
       
   598 	cluster>>iDes;
       
   599 	TUint8** map=&iMap[0];
       
   600 	TUint8* base=*map;
       
   601 	TUint8* ptr=base;
       
   602 	for (TUint members=iDes.iMembership;members!=0;members>>=1)
       
   603 		{
       
   604 		if (members&1)
       
   605 			{
       
   606 			TCardinality card;
       
   607 			cluster >> card;
       
   608 			TInt size=card;
       
   609 			if (size>KDbStoreMaxRecordLength)
       
   610 				__LEAVE(KErrCorrupt);
       
   611 			ptr+=size;
       
   612 			}
       
   613 		*++map=ptr;
       
   614 		}
       
   615 	while (map<&iMap[KMaxClustering])
       
   616 		*++map=ptr;
       
   617 	TInt len=ptr-base;
       
   618 	base+=SetSizeL(len);
       
   619 	cluster.FilterL(cluster.EMixed,aCluster);
       
   620 	cluster.ReadL(base,len);
       
   621 	CleanupStack::PopAndDestroy();
       
   622 	iCluster=aCluster;
       
   623 	}
       
   624 
       
   625 void CCluster::SetRecordL(TInt aIndex,TInt aNewSize)
       
   626 	{
       
   627 	AdjustL(&iMap[aIndex],iMap[aIndex]+aNewSize-iMap[aIndex+1],iMap[aIndex+1]);
       
   628 	iModified=ETrue;
       
   629 	}
       
   630 
       
   631 void CCluster::AdjustL(TUint8** aMapEntry,TInt aAdjust,TUint8* aData)
       
   632 //
       
   633 // Adjust the record at map entry by aAdjust bytes
       
   634 // Move that entry data as well as the ones following for AlterCluster
       
   635 //
       
   636 	{
       
   637 	if (!aAdjust)
       
   638 		return;
       
   639 //
       
   640 	__ASSERT(aAdjust+aMapEntry[1]>=aMapEntry[0]);	// record cannot go -ve size
       
   641 	__ASSERT(aData>=aMapEntry[0]);					// must not save data before this record
       
   642 //
       
   643 	aData+=SetSizeL(iMap[KMaxClustering]-iMap[0]+aAdjust);
       
   644 	Mem::Copy(aData+aAdjust,aData,iMap[KMaxClustering]-aData);
       
   645 	AdjustMap(aMapEntry+1,aAdjust);
       
   646 	}
       
   647 
       
   648 // class CCluster::MAlter
       
   649 
       
   650 TInt CCluster::MAlter::RecordExpansion(const TUint8*,TInt)
       
   651 //
       
   652 // default to no expansion
       
   653 //
       
   654 	{
       
   655 	return 0;
       
   656 	}