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

Function CodeHolder_reserveInternal

libraries/asmjit/asmjit/base/codeholder.cpp:270–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268// ============================================================================
269
270static Error CodeHolder_reserveInternal(CodeHolder* self, CodeBuffer* cb, size_t n) noexcept {
271 uint8_t* oldData = cb->_data;
272 uint8_t* newData;
273
274 if (oldData && !cb->isExternal())
275 newData = static_cast<uint8_t*>(Internal::reallocMemory(oldData, n));
276 else
277 newData = static_cast<uint8_t*>(Internal::allocMemory(n));
278
279 if (ASMJIT_UNLIKELY(!newData))
280 return DebugUtils::errored(kErrorNoHeapMemory);
281
282 cb->_data = newData;
283 cb->_capacity = n;
284
285 // Update the `Assembler` pointers if attached. Maybe we should introduce an
286 // event for this, but since only one Assembler can be attached at a time it
287 // should not matter how these pointers are updated.
288 Assembler* a = self->_cgAsm;
289 if (a && &a->_section->_buffer == cb) {
290 size_t offset = a->getOffset();
291
292 a->_bufferData = newData;
293 a->_bufferEnd = newData + n;
294 a->_bufferPtr = newData + offset;
295 }
296
297 return kErrorOk;
298}
299
300Error CodeHolder::growBuffer(CodeBuffer* cb, size_t n) noexcept {
301 // This is most likely called by `Assembler` so `sync()` shouldn't be needed,

Callers 2

growBufferMethod · 0.85
reserveBufferMethod · 0.85

Calls 5

reallocMemoryFunction · 0.85
allocMemoryFunction · 0.85
erroredFunction · 0.85
isExternalMethod · 0.45
getOffsetMethod · 0.45

Tested by

no test coverage detected