MCPcopy Create free account
hub / github.com/apache/madlib / resize

Method resize

src/dbal/ByteStreamHandleBuf_impl.hpp:97–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96template <class Storage, class CharType>
97void
98ByteStreamHandleBuf<Storage, CharType, Mutable>::resize(
99 size_t inSize, size_t inPivot) {
100
101 if (inSize == this->size())
102 return;
103
104 char_type* oldPtr = this->ptr();
105 size_t secondChunkStart
106 = inPivot > this->size() ? this->size() : inPivot;
107 size_t oldSize = this->size();
108 ptrdiff_t delta = inSize - oldSize;
109
110 // FIXME: Deallocate old memory!
111 this->mStorage = defaultAllocator().allocateByteString<
112 dbal::FunctionContext, dbal::DoZero, dbal::ThrowBadAlloc>(inSize);
113
114 std::copy(oldPtr, oldPtr + secondChunkStart, this->ptr());
115 std::copy(oldPtr + secondChunkStart, oldPtr + oldSize,
116 this->ptr() + secondChunkStart + delta);
117 std::fill(this->ptr() + secondChunkStart,
118 this->ptr() + secondChunkStart + delta, 0);
119}
120
121} // namespace dbal
122

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.95
ptrMethod · 0.95

Tested by

no test coverage detected