MCPcopy Create free account
hub / github.com/SmingHub/Sming / moveString

Method moveString

Sming/Core/Data/Stream/LimitedMemoryStream.cpp:70–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70bool LimitedMemoryStream::moveString(String& s)
71{
72 // If we don't own the memory buffer, this operation is unsafe
73 if(!owned) {
74 s = nullptr;
75 return false;
76 }
77
78 // Ensure size < capacity
79 size_t size{writePos};
80 bool sizeOk;
81 if(size < capacity) {
82 ++size;
83 sizeOk = true;
84 } else {
85 sizeOk = false;
86 }
87
88 bool res = s.setBuffer({buffer, capacity, size - 1});
89 (void)res;
90 assert(res);
91
92 owned = false;
93 buffer = nullptr;
94 capacity = 0;
95 writePos = 0;
96 readPos = 0;
97 return sizeOk;
98}

Callers

nothing calls this directly

Calls 1

setBufferMethod · 0.45

Tested by

no test coverage detected