pair<void*,uint64_t> IOBufQueue::preallocateSlow(uint64_t min, uint64_t newAllocationSize, uint64_t max) { // Allocate a new buffer of the requested max size. unique_ptr<IOBuf> newBuf(IOBuf::create(std::max(min, newAllocationSize))); appendToChain(head_, std::move(newBuf), false); IOBuf* last = head_->prev(); return make_pair(last->writableTail(), std::min(max, last->tailroom())); }
pair<void*,uint64_t> IOBufQueue::preallocateSlow(uint64_t min, uint64_t newAllocationSize, uint64_t max) { // Avoid grabbing update guard, since we're manually setting the cache ptrs. flushCache(); // Allocate a new buffer of the requested max size. unique_ptr<IOBuf> newBuf(IOBuf::create(std::max(min, newAllocationSize))); tailStart_ = newBuf->writableTail(); cachePtr_->cachedRange = std::pair<uint8_t*, uint8_t*>( tailStart_, tailStart_ + newBuf->tailroom()); appendToChain(head_, std::move(newBuf), false); return make_pair(writableTail(), std::min<uint64_t>(max, tailroom())); }
tstring Utility::GetRegStringValue(CRegKey& reg, LPCTSTR szValueName) { DWORD dwBufSize = 512; TCHAR szBuf[512] = {0}; LONG lRes = reg.QueryStringValue(szValueName, szBuf, &dwBufSize); if (lRes == ERROR_SUCCESS) return szBuf; if (lRes != ERROR_MORE_DATA) return _T(""); // unknown error // allocate more memory boost::scoped_array<TCHAR> newBuf(new TCHAR[dwBufSize]); lRes = reg.QueryStringValue(szValueName, newBuf.get(), &dwBufSize); if (lRes != ERROR_SUCCESS) return _T(""); // unknown error return newBuf.get(); }
GLDEF_C void TestTDes<T,S,L,R>::Test15() // // Constructor over a TBufC // { T oldBuf(_TL("Test 15")); oldBuf.__DbgTestInvariant(); T newBuf(oldBuf); newBuf.__DbgTestInvariant(); test(newBuf.Length()==8); test(newBuf.Length()==oldBuf.Length()); test(*(newBuf.Ptr())=='T'); test(*(newBuf.Ptr()+1)=='e'); test(*(newBuf.Ptr()+2)=='s'); test(*(newBuf.Ptr()+3)=='t'); test(*(newBuf.Ptr()+4)==' '); test(*(newBuf.Ptr()+5)==' '); test(*(newBuf.Ptr()+6)=='1'); test(*(newBuf.Ptr()+7)=='5'); }