text
stringlengths
0
2.2M
}
// Note: Moving this function into the header may cause performance regression.
template <class Size_T>
void SmallVectorBase<Size_T>::grow_pod(
void* FirstEl,
size_t MinSize,
size_t TSize) {
size_t NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
void* NewElts;
if (BeginX == FirstEl) {
NewElts = std::malloc(NewCapacity * TSize);
if (NewElts == nullptr) {
throw std::bad_alloc();
}
// Copy the elements over. No need to run dtors on PODs.
memcpy(NewElts, this->BeginX, size() * TSize);
} else {
// If this wasn't grown from the inline copy, grow the allocated space.
NewElts = std::realloc(this->BeginX, NewCapacity * TSize);
if (NewElts == nullptr) {
throw std::bad_alloc();
}
}
this->BeginX = NewElts;
this->Capacity = NewCapacity;
}
template class c10::SmallVectorBase<uint32_t>;
// Disable the uint64_t instantiation for 32-bit builds.
// Both uint32_t and uint64_t instantiations are needed for 64-bit builds.
// This instantiation will never be used in 32-bit builds, and will cause
// warnings when sizeof(Size_T) > sizeof(size_t).
#if SIZE_MAX > UINT32_MAX
template class c10::SmallVectorBase<uint64_t>;
// Assertions to ensure this #if stays in sync with SmallVectorSizeType.
static_assert(
sizeof(SmallVectorSizeType<char>) == sizeof(uint64_t),
"Expected SmallVectorBase<uint64_t> variant to be in use.");
#else
static_assert(
sizeof(SmallVectorSizeType<char>) == sizeof(uint32_t),
"Expected SmallVectorBase<uint32_t> variant to be in use.");
#endif
/*
Copyright 2009-2013, Sumeet Chhetri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* DistoCacheClientUtils.cpp
*
* Created on: 04-Apr-2013
* Author: sumeetc
*/
#include "DistoCacheClientUtils.h"
std::string DistoCacheClientUtils::ERR_NOELEMENTS = "No Elements in container", DistoCacheClientUtils::ERR_NOKEYCACHEMAP = "Unable to find value for Key specified",
DistoCacheClientUtils::ERR_INVCONTAINER = "Invalid container specified", DistoCacheClientUtils::ERR_OPNOTSUPP = "Operation not supported on container",
DistoCacheClientUtils::ERR_INDGRTCONTSIZ = "Index greater than container size", DistoCacheClientUtils::ERR_NOTAMAPCONT = "Not a map container",
DistoCacheClientUtils::ERR_NOVALUEFOUND = "No value found for key", DistoCacheClientUtils::ERR_ALLOCENTEXISTS = "Entry already exists",
DistoCacheClientUtils::ERR_NOVALUESPEC = "No value specified", DistoCacheClientUtils::ERR_NEGATIVEPOS = "Position value is less than 0",
DistoCacheClientUtils::ERR_POSNOTNUM = "Position value is not a number", DistoCacheClientUtils::ERR_NEGATIVEREP = "Repetition value is less than 0",
DistoCacheClientUtils::ERR_REPNOTNUM = "Repetition value is not a number", DistoCacheClientUtils::SUCCESS = "SUCCESS";
DistoCacheClientUtils::DistoCacheClientUtils(const std::string& host, const int& port, const bool& isSSL) {
if(isSSL)
{
client = new SSLClient;
}
else
{
client = new Client;
}
bool connected = client->connection(host, port);
if(!connected)
{
delete client;
throw std::runtime_error("Error connecting to " + host + ":" + CastUtil::fromNumber(port));
}
inUse = false;
}