コード例 #1
0
ファイル: StringRef.cpp プロジェクト: akhanzode/voltdb
StringRef* StringRef::create(int32_t sz, const char* source, Pool* tempPool)
{
    /*/ enable to debug
    if (source) {
        std::cout << "DEBUG: setting [" << sz << "]" << std::string(source, sz) << std::endl;
    }
    else {
        std::cout << "DEBUG: setting up [" << sz << "]" << std::endl;
    }
    // */
    StringRef* result;
    if (tempPool) {
        result = new (tempPool->allocate(sizeof(StringRef)+sizeof(ThreadLocalPool::Sized) + sz)) StringRef(tempPool, sz);
    }
    else {
#ifdef MEMCHECK
        result = new StringRef(sz);
#else
        result = new (ThreadLocalPool::allocateExactSizedObject(sizeof(StringRef))) StringRef(sz);
#endif
    }
    if (source) {
        ::memcpy(result->getObjectValue(), source, sz);
    }
    return result;
}
コード例 #2
0
ファイル: StringRef.cpp プロジェクト: akhanzode/voltdb
StringRef* StringRef::create(int32_t sz, const char* source, LargeTempTableBlock* lttBlock)
{
    assert (lttBlock != NULL);
    StringRef* result;
    result = new (lttBlock->allocate(sizeof(StringRef)+sizeof(ThreadLocalPool::Sized) + sz)) StringRef(NULL, sz);

    if (source) {
        ::memcpy(result->getObjectValue(), source, sz);
    }

    return result;

}