MCPcopy Create free account
hub / github.com/ZDoom/Raze / reserve

Method reserve

libraries/asmjit/asmjit/base/string.cpp:129–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129ASMJIT_FAVOR_SIZE Error StringBuilder::reserve(size_t to) noexcept {
130 if (_capacity >= to)
131 return kErrorOk;
132
133 if (to >= IntTraits<size_t>::maxValue() - sizeof(intptr_t) * 2)
134 return DebugUtils::errored(kErrorNoHeapMemory);
135
136 to = Utils::alignTo<size_t>(to, sizeof(intptr_t));
137 char* newData = static_cast<char*>(Internal::allocMemory(to + sizeof(intptr_t)));
138
139 if (!newData)
140 return DebugUtils::errored(kErrorNoHeapMemory);
141
142 ::memcpy(newData, _data, _length + 1);
143 if (_canFree)
144 Internal::releaseMemory(_data);
145
146 _data = newData;
147 _capacity = to + sizeof(intptr_t) - 1;
148 _canFree = true;
149 return kErrorOk;
150}
151
152// ============================================================================
153// [asmjit::StringBuilder - Clear]

Callers 3

reorderMethod · 0.45
ShowErrorPaneMethod · 0.45
SetTextMethod · 0.45

Calls 3

erroredFunction · 0.85
allocMemoryFunction · 0.85
releaseMemoryFunction · 0.85

Tested by

no test coverage detected