MCPcopy Create free account
hub / github.com/couchbase/fleece / createStr

Method createStr

Fleece/Mutable/HeapValue.cc:112–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110
111
112 HeapValue* HeapValue::createStr(tags valueTag, slice s) {
113 uint8_t sizeBuf[kMaxVarintLen32];
114 size_t sizeByteCount = 0;
115 int tiny;
116 if (s.size < 0x0F) {
117 tiny = (int)s.size;
118 } else {
119 tiny = 0x0F;
120 sizeByteCount = PutUVarInt(&sizeBuf, s.size);
121 }
122 auto hv = new (sizeByteCount + s.size) HeapValue(valueTag, tiny);
123 uint8_t *strData = &hv->_header + 1;
124 memcpy(strData, sizeBuf, sizeByteCount);
125 memcpy(strData + sizeByteCount, s.buf, s.size);
126 return hv;
127 }
128
129
130 HeapValue* HeapValue::create(const Value *v) {

Callers

nothing calls this directly

Calls 1

PutUVarIntFunction · 0.85

Tested by

no test coverage detected