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

Method getBuffer

Sming/Wiring/WString.cpp:200–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200String::Buffer String::getBuffer()
201{
202 String::Buffer buf;
203 if(sso.set) {
204 buf.size = sso.len + 1;
205 buf.length = sso.len;
206 buf.data = static_cast<char*>(malloc(buf.size));
207 memcpy(buf.data, sso.buffer, sso.len);
208 buf.data[sso.len] = '\0';
209 } else {
210 buf.data = ptr.buffer;
211 buf.size = ptr.capacity + 1;
212 buf.length = ptr.len;
213 }
214 sso.set = false;
215 ptr.buffer = nullptr;
216 ptr.capacity = 0;
217 ptr.len = 0;
218
219 return buf;
220}
221
222bool String::setBuffer(const Buffer& buffer)
223{

Callers 1

Calls 1

mallocFunction · 0.85

Tested by

no test coverage detected