MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Realloc

Method Realloc

src/script/squirrel.cpp:124–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122 }
123
124 void *Realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size)
125 {
126 if (p == nullptr) {
127 return this->Malloc(size);
128 }
129 if (size == 0) {
130 this->Free(p, oldsize);
131 return nullptr;
132 }
133
134 this->CheckAllocationAllowed(size - oldsize);
135
136 void *new_p = this->DoAlloc(size);
137 std::copy_n(static_cast<std::byte *>(p), std::min(oldsize, size), static_cast<std::byte *>(new_p));
138 this->Free(p, oldsize);
139
140 return new_p;
141 }
142
143 void Free(void *p, SQUnsignedInteger size)
144 {

Callers 1

sq_vm_reallocFunction · 0.80

Calls 4

MallocMethod · 0.95
FreeMethod · 0.95
DoAllocMethod · 0.95

Tested by

no test coverage detected