当前位置: 首页>>代码示例>>C++>>正文


C++ RBuf8::ReAllocL方法代码示例

本文整理汇总了C++中RBuf8::ReAllocL方法的典型用法代码示例。如果您正苦于以下问题:C++ RBuf8::ReAllocL方法的具体用法?C++ RBuf8::ReAllocL怎么用?C++ RBuf8::ReAllocL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RBuf8的用法示例。


在下文中一共展示了RBuf8::ReAllocL方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ServiceL

void CSandboxSession::ServiceL(const RMessage2 &aMessage)
	{
	if (aMessage.Function() >= EMaxArgs)
		{
		aMessage.Complete(KErrArgument);
		return;
		}

	if (aMessage.Function() == EGetRecog2)
		{
		aMessage.WriteL(0, iBuf);
		iBuf.Close();
		aMessage.Complete(KErrNone);
		}
	else if (aMessage.Function() == EGetRecog)
		{
		if (iBuf.MaxLength() == 0)
			{
			iBuf.ReAllocL(1024); // Must be > sizeof(TDataType) otherwise the reallocating logic below is flawed
			}
		TUid uid = TUid::Uid(aMessage.Int0());
		TUid destructorKey;
		CApaDataRecognizerType* rec = static_cast<CApaDataRecognizerType*>(REComSession::CreateImplementationL(uid, destructorKey));
		TInt count = rec->MimeTypesCount();
		for (TInt j = 0; j < count; j++)
			{
			TDataType type = rec->SupportedDataTypeL(j);
			TPckg<TDataType> buf(type);
			if (iBuf.Length() + buf.Length() >= iBuf.MaxLength())
				{
				iBuf.ReAllocL(iBuf.MaxLength() * 2);
				}
			iBuf.Append(buf);
			}

		aMessage.Complete(iBuf.Size());
		}
	else if (aMessage.Function() == ECloseServer)
		{
		aMessage.Complete(KErrNone);
		CActiveScheduler::Stop();
		}
	else if (aMessage.Function() == EGetVTablePtr)
		{
		TUid destructorKey;
		TAny* obj = NULL;
		obj = REComSession::CreateImplementationL(TUid::Uid(aMessage.Int0()), destructorKey);
		TAny* vtablePtr = *((TAny**)obj);	
		TPckg<TAny*> res(vtablePtr);
		aMessage.WriteL(1, res);
		aMessage.Complete(KErrNone);
		}
	else
		{
		ASSERT(0);
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:57,代码来源:sandbox.cpp

示例2: getValueL

void CPublishAndSubscribeHandler::getValueL(unsigned long key, RBuf8& value)
{
    TInt err = RProperty::Get(m_uid, key, value);
    if (err == KErrOverflow)
    {
        value.ReAllocL(RProperty::KMaxPropertySize);
        err = RProperty::Get(m_uid, key, value);
        if (err == KErrOverflow)
        {
            value.ReAllocL(RProperty::KMaxLargePropertySize);
            err = RProperty::Get(m_uid, key, value);
        }
    }
    User::LeaveIfError(err);
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:15,代码来源:cpublishandsubscribehandler.cpp

示例3:

// -----------------------------------------------------------------------------
// XIMPRBuf8Helper::GrowIfNeededL()
// -----------------------------------------------------------------------------
//
EXPORT_C void XIMPRBuf8Helper::GrowIfNeededL( RBuf8& aBuf, const TInt aMaxLength )
    {
    if ( aBuf.MaxLength() < aMaxLength )
        {
        aBuf.ReAllocL( aMaxLength );
        }
    }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:11,代码来源:ximprbufhelpers.cpp

示例4: DoGetListL

void CServerCrashDataSource::DoGetListL(const TListId aListId, 
										const TThreadId aThreadId,
										const TProcessId aProcessId,
										RBuf8 & aBuffer, 
										TUint32 & aSize )
	{

	LOG_MSG5( "->CServerCrashDataSource::DoGetList(aListId=%d, aThredId=%Lu, aProcessId=%Lu, aSize=%d\n", aListId, aThreadId.Id(), aProcessId.Id(), aSize );

	TInt ret;
	TListLevel listLevel;

	if( ((TUint)-1 == (TUint)aThreadId) && ((TUint)-1 == (TUint)aProcessId) )
		{
		listLevel = EListGlobal;
		ret = iSecSess.GetList( aListId, aBuffer, aSize );
		}
	else if( ((TUint)-1 != (TUint)aThreadId) && ((TUint)-1 == (TUint)aProcessId) )
		{
		listLevel = EListThread;
        LOG_MSG("CServerCrashDataSource::DoGetList - EListThread");
		ret = iSecSess.GetList( aThreadId, aListId, aBuffer, aSize );
		}
	else
		{
		listLevel = EListProcess;
        LOG_MSG("CServerCrashDataSource::DoGetList - EListProcess");
		ret = iSecSess.GetList( aProcessId, aListId, aBuffer, aSize );
		}
		 
	while( KErrTooBig == ret )
		{
		LOG_MSG2( "CServerCrashDataSource::DoGetListL - list too big, new size=%d\n", aSize );

		// Too big, and aSize should have been modified to the required new size
		// Since the list could have increased in size between calls, give it an 
		// extra margin.
		aSize += 256;

		aBuffer.ReAllocL( aSize );

		if( EListGlobal == listLevel )
			{
			ret = iSecSess.GetList( aListId, aBuffer, aSize );
			}
		else if( EListThread == listLevel )
			{
			ret = iSecSess.GetList( aThreadId, aListId, aBuffer, aSize );
			}
		else
			{
			ret = iSecSess.GetList( aProcessId, aListId, aBuffer, aSize );
			}

		}
    User::LeaveIfError(ret);
	}
开发者ID:fedor4ever,项目名称:devicedbgsrvs,代码行数:57,代码来源:servercrashdatasource.cpp

示例5:

void CAsn1PerOctetString::DecodeL(const TDesC8& aBuf,
                                  const TInt aStartBit,
                                  const TBool aLengthIsVariable,
                                  const TBool aLengthIsConstrained,
                                  const TInt aMinLength,
                                  const TInt aMaxLength,
                                  const TBool aIsExtensible,
                                  const TBool /*aIsPadded*/,
                                  TBool& aIsExtended,
                                  TInt& aBitsDecoded,
                                  RBuf8& aDecodedBuf)
{

    TInt currentBitPos=aStartBit;
    TInt bitDecoded=0;
    aBitsDecoded=0;
    aIsExtended=EFalse;
    TInt stringLen=0;

    CAsn1PerUtil::DecodeStringEBitAndLengthL(aBuf,
            currentBitPos,
            aLengthIsVariable,
            aLengthIsConstrained,
            aMinLength,
            aMaxLength,
            aIsExtensible,
            aIsExtended,
            bitDecoded,
            stringLen);

    currentBitPos+=bitDecoded;
    aBitsDecoded+=bitDecoded;
    bitDecoded=0;

    //check if the input buffer is long enough
    if (currentBitPos+stringLen*8>aBuf.Length()*8)
    {
        User::Leave(KErrUnderflow);
    }

    //Finally, decode the string content for cases
    aDecodedBuf.ReAllocL(stringLen);
    aDecodedBuf.SetLength(stringLen);
    aDecodedBuf.FillZ();

    TInt stringBitLength=stringLen*8;

    //Copy the String to the Dest Buffer .
    TInt destBitNum=8;
    TInt destOctetNum=0;

    //Copy ...
    CAsn1PerUtil::CopyDataTrunkL(aBuf, currentBitPos, stringBitLength, aDecodedBuf, destOctetNum, destBitNum);
    aBitsDecoded+=stringBitLength;
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:55,代码来源:asn1peroctetstring.cpp

示例6: SerializeArrayL

EXPORT_C void SoftwareTypeRegInfoUtils::SerializeArrayL(const RPointerArray<Usif::CSoftwareTypeRegInfo>& aSwTypeRegInfoArray, RBuf8& aSerializedArray)
	{
	TInt bufLen = sizeof(TInt);
	const TInt count = aSwTypeRegInfoArray.Count();
	for (TInt i=0; i<count; ++i)
	    {
	    bufLen += GetObjectSizeL(aSwTypeRegInfoArray[i]);
	    }

	aSerializedArray.ReAllocL(aSerializedArray.Length()+bufLen);
	RDesWriteStream ws(aSerializedArray);
	CleanupClosePushL(ws);

	ExternalizePointerArrayL(aSwTypeRegInfoArray, ws);

	ws.CommitL();
	CleanupStack::PopAndDestroy(&ws);
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:18,代码来源:swtypereginfo.cpp

示例7: ToStringL

void CDnsUpdateOption::ToStringL(RBuf8& aBuf8) const
/**
  * Writes DNS update option data to a string suitable for sending out
  * on to the network
  *
  * @internalTechnology
  * 
  */
	{
	RBuf8 encodedDomainName;
	encodedDomainName.CleanupClosePushL();

	TDomainNameArray domainNames;
	CleanupClosePushL(domainNames);
	domainNames.AppendL(iDomainName);

	CDomainNameCodec* domainNameEncoder = new(ELeave) CDomainNameCodec();
	CleanupStack::PushL(domainNameEncoder);


	domainNameEncoder->EncodeL(domainNames, encodedDomainName);


	CleanupStack::PopAndDestroy(domainNameEncoder);
	CleanupStack::PopAndDestroy(&domainNames); // closes the RBuf8	


	aBuf8.Zero();

	aBuf8.ReAllocL( 3 + encodedDomainName.Length() );

	aBuf8.Append((TChar)(iFlags.Value()));
	aBuf8.Append((TChar)iRCode1);
	aBuf8.Append((TChar)iRCode2);
	aBuf8.Append(encodedDomainName);

	CleanupStack::PopAndDestroy(&encodedDomainName); // closes the array
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:38,代码来源:DHCPIP4Msg.cpp

示例8: EncodeL

void CDomainNameCodec::EncodeL(TDomainNameArray& aNames, RBuf8& aBuf8)
	{
	TUint requiredLength = 0;
	TUint8 nameIdx = 0;
	
	for (nameIdx=0;nameIdx<aNames.Count();nameIdx++)
		{
		// The total length required for the labels that comprise an
		// individual domain name needs to take into the length octet
		// for the initial label and the null-termination character.
		// Hence the '+ 2' below.
		requiredLength += (aNames[nameIdx].Length() + 2);		
		
		// A further length check is performed on each domain name to
		// ensure it does not exceed the maximum length permitted according
		// to RFC 1035.
		if(aNames[nameIdx].Length() > KMaxDomainNameLength)
			{
			User::Leave(KErrArgument);
			}
		}		
	
	aBuf8.Zero();
	aBuf8.ReAllocL(requiredLength);
	
	TLex8 domainName;
	TPtrC8 currentLabel;
	
	for (nameIdx=0;nameIdx<aNames.Count();nameIdx++)
		{
		domainName.Assign(aNames[nameIdx]);		
		domainName.Mark();
		
		while (!domainName.Eos())
			{
			TChar ch;
			do
				{
				ch = domainName.Get();
				}
			while ( ch != TChar('.') && !domainName.Eos() );
			
			// if not the end of the string, unget the previous char to skip the trailing
			//  dot in our marked token
			//
			if( !domainName.Eos() )
				{
				domainName.UnGet();
				}
			
			currentLabel.Set(domainName.MarkedToken());
			
			// move past the dot again, or do nothing in particular at EOS
			//
			domainName.Get();
			
			User::LeaveIfError(currentLabel.Length() > KMaxDnsLabelLength ? 
				KErrArgument : KErrNone);
			
			aBuf8.Append(TChar(currentLabel.Length()));
			aBuf8.Append(currentLabel);
			
			domainName.Mark();
			}
		
		aBuf8.Append(TChar(0));
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:68,代码来源:DomainNameDecoder.cpp

示例9: SerializeL

// --------------------------------------------------------------------------------------
// Serializes TXmlEngNode to buffer
// --------------------------------------------------------------------------------------
//
TInt CXmlEngSerializerXOP::SerializeL( RBuf8& aBuffer, 
                                    const TXmlEngNode aRoot, 
									const TXmlEngSerializationOptions& aOptions )
    {
    if(aBuffer.Length())
        {
        aBuffer.Close();
        }
	LeaveIfXopIncludeL(aRoot);
    iDataContainerArray.Reset();	    
    if(aOptions.iDataSerializer)
    	{
    	return CXmlEngSerializer::SerializeL(aBuffer, aRoot, aOptions);
    	}    
    	
	TXmlEngSerializationOptions opt = aOptions;
	opt.iDataSerializer = this;
			
	RBuf8 xopDocument;
	CleanupClosePushL(xopDocument);
	aRoot.OwnerDocument().SaveL(xopDocument, aRoot, opt);

	if( iCleanXOPInfoset )		
		{
		if(xopDocument.Size() > aBuffer.MaxSize())
		    {
		    aBuffer.ReAllocL( xopDocument.Size() );
		    }
		aBuffer.Append(xopDocument);		
		}
	else		
		{    
	    // adjust buffer size
		TInt bufSize = KXOPDocumentStart().Size() 
					+ KMimeRoot().Size() 
					+ xopDocument.Size()
					+ KXOPDocumentEnd().Size();
		for(TInt j = 0; j < iDataContainerArray.Count(); j++)	
			{
			TPtrC8 contentTypeStr;
			if(GetContentTypeValue(iDataContainerArray[j], contentTypeStr))
				{
				bufSize += KMimeHeaderContentType().Size() 
						+ contentTypeStr.Size() 
						+ KNewLine().Size();					
				}
			bufSize += KMimeHeaderStart().Size() 
					+ KMimeHeaderContentIdStart().Size()
					+ iDataContainerArray[j].Cid().Length()
					+ KMimeHeaderContentIdEnd().Size()
					+ KNewLine().Size()
					+ iDataContainerArray[j].Size(); 
			}
		if (bufSize > aBuffer.MaxSize())
		    {
		    aBuffer.ReAllocL( bufSize );
		    }
		    
		// write to buffer
		aBuffer.Append(KXOPDocumentStart());
		aBuffer.Append(KMimeRoot());
		aBuffer.Append(xopDocument);
		for(TInt i = 0; i < iDataContainerArray.Count(); i++)	
			{
			aBuffer.Append(KMimeHeaderStart);
			TPtrC8 contentTypeStr;
			if(GetContentTypeValue(iDataContainerArray[i], contentTypeStr))
				{	
				aBuffer.Append(KMimeHeaderContentType);
				aBuffer.Append(contentTypeStr);
				aBuffer.Append(KNewLine);
				}
			aBuffer.Append(KMimeHeaderContentIdStart);				
			aBuffer.Append(iDataContainerArray[i].Cid());
			aBuffer.Append(KMimeHeaderContentIdEnd);
			aBuffer.Append(KNewLine);	
			switch(iDataContainerArray[i].NodeType())
				{
				case TXmlEngNode::EBinaryContainer:
					{
					if(opt.iOptions & TXmlEngSerializationOptions::KOptionDecodeBinaryContainers )	
						{						
						HBufC8* decodedData = CreateDecodedBufLC(iDataContainerArray[i].AsBinaryContainer().Contents());
						aBuffer.Append(decodedData->Des());
						CleanupStack::PopAndDestroy(); //decodedData
						}
					else
						{
						aBuffer.Append(iDataContainerArray[i].AsBinaryContainer().Contents());							
						}
					break;
					}
				case TXmlEngNode::EChunkContainer:
					{
					TPtrC8 data = TPtrC8(
						((RChunk&)iDataContainerArray[i].AsChunkContainer().Chunk()).Base()
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,代码来源:xmlengserializerxop.cpp

示例10: ptr

void CDHCPMessageHeaderIP4::FinishL(TDesC8& aClientId)
/**
  * Put finishing touches to message for sending
  * Basically copies in the magic cookie (99.130.83.99)
  * and the end marker then set the length of the descriptor
  * as we have been pushing data into the descriptor manually
  *
  * @param aClientId The client ID string to be added to the message
  * @see RFC 2131 for explanation of the magic cookie!
  *
  * @internalTechnology
  */
#endif //SYMBIAN_NETWORKING_DHCP_MSG_HEADERS
	{
	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPMessageBase::FinishL")));
	
#ifdef SYMBIAN_NETWORKING_DHCPSERVER
	if(!iDHCPServerImpl)
	{
#endif // SYMBIAN_NETWORKING_DHCPSERVER	
	
	TUint8 reqListArray[KDhcpParameterRequestListLen] = {EDHCPHostName, EDHCPDomainNameServer, 
							EDHCPDomainName, EDHCPSubnetMask, EDHCPRouter, EDHCPBroadcastAddr, EDHCPSIPServers};
	TPtr8 ptr(reqListArray, KDhcpParameterRequestListLen, KDhcpParameterRequestListLen);
	
	// +++++++++++++++++++++++ Client ID +++++++++++++++++++++++++++++++++++++++++/
	AddOptionL(EDHCPClientID, aClientId.Length())->GetBodyDes().Copy(aClientId);
		
#ifdef SYMBIAN_NETWORKING_DHCP_MSG_HEADERS
	RBuf8 appendOpCodeList;
	appendOpCodeList.CreateL(ptr);
	if (aOptionsPtr)
		{
		TInt optLen=aOptionsPtr->Length();
		appendOpCodeList.ReAllocL(KDhcpParameterRequestListLen+optLen);
		appendOpCodeList.Append(aOptionsPtr->Ptr(),optLen);
		}
	AddOptionL(EDHCPParameterReqList, appendOpCodeList.Length())->GetBodyDes().Copy(appendOpCodeList);
	appendOpCodeList.Close();
#else
	// +++++++++++++++++++++++ Parameter Request List ++++++++++++++++++++++++++++/
	AddOptionL(EDHCPParameterReqList, ptr.Length())->GetBodyDes().Copy(ptr);
#endif		
	// +++++++++++++++++++++++ Maximum message size (2 bytes) ++++++++++++++++++++/
	AddOptionL(EDHCPMaxMsgSize, 2)->SetBigEndian(KDhcpMaxMsgSizeIP4);
	
#ifdef SYMBIAN_NETWORKING_DHCPSERVER
	}
#endif // SYMBIAN_NETWORKING_DHCPSERVER	
		
	TInetAddr magic;
	_LIT(magicCookie, "99.83.130.99");
	User::LeaveIfError(magic.Input(magicCookie));	// essential the magic cookie is correct
	iCookie.SetLittleEndian(magic.Address());
		
	ASSERT(!iOptions.FindOption(EDHCPEnd));
	AddOptionL(EDHCPEnd, 0);

   //add padding if msg shorter than 300 bytes
 	TInt len=iMsg->Length();
 	TPtr8 des=iMsg->Des();
	if (len<300)
      {
		des.AppendFill(EDHCPPad, 300-len);
      }
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:66,代码来源:DHCPIP4Msg.cpp


注:本文中的RBuf8::ReAllocL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。