MCPcopy Create free account
hub / github.com/Kitware/VTK / SetBuffer

Method SetBuffer

IO/Core/vtkMemoryResourceStream.cxx:21–48  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

19
20//------------------------------------------------------------------------------
21void vtkMemoryResourceStream::SetBuffer(const void* buffer, std::size_t size, bool copy)
22{
23 if (buffer == nullptr && size != 0)
24 {
25 vtkErrorMacro("buffer must not be nullptr if size > 0");
26 return;
27 }
28
29 this->Size = size;
30 this->Pos = 0;
31 this->Eos = (this->Size == 0);
32 this->Holder.reset();
33
34 if (copy && size > 0)
35 {
36 std::unique_ptr<unsigned char[]> ptr{ new unsigned char[size] };
37 std::memcpy(ptr.get(), buffer, size);
38
39 this->Buffer = ptr.get();
40 this->Holder = MakeHolder(std::move(ptr));
41 }
42 else
43 {
44 this->Buffer = static_cast<const unsigned char*>(buffer);
45 }
46
47 this->Modified();
48}
49
50//------------------------------------------------------------------------------
51std::size_t vtkMemoryResourceStream::Read(void* buffer, std::size_t bytes)

Callers 15

LoadImageDataMethod · 0.45
TestOFFReaderFunction · 0.45
ToMemoryStreamFunction · 0.45
ReadPNGFromStreamMethod · 0.45
LoadDataMethod · 0.45
SetBufferFunction · 0.45
TestIntParseFunction · 0.45
TestFloatParseFunction · 0.45
TestBoolParseFunction · 0.45
TestReadLineFunction · 0.45
TestReadLineLimitFunction · 0.45

Calls 4

MakeHolderFunction · 0.85
resetMethod · 0.45
getMethod · 0.45
ModifiedMethod · 0.45

Tested by 13

TestOFFReaderFunction · 0.36
TestIntParseFunction · 0.36
TestFloatParseFunction · 0.36
TestBoolParseFunction · 0.36
TestReadLineFunction · 0.36
TestReadLineLimitFunction · 0.36
TestReadLineToFunction · 0.36
TestStringParseFunction · 0.36
TestStopOnNewLineFunction · 0.36
TestDiscardPredicateFunction · 0.36
TestMemoryResourceFunction · 0.36
TestOwnedMemoryResourceFunction · 0.36