MCPcopy Create free account
hub / github.com/catboost/catboost / realloc

Function realloc

library/cpp/lfalloc/lf_allocX64.cpp:103–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103extern "C" void* realloc(void* old_ptr, size_t new_size) {
104 if (old_ptr == nullptr) {
105 void* result = LFAlloc(new_size);
106 return result;
107 }
108 if (new_size == 0) {
109 LFFree(old_ptr);
110 return nullptr;
111 }
112
113 void* new_ptr = LFAlloc(new_size);
114 if (new_ptr == nullptr) {
115 return nullptr;
116 }
117 size_t old_size = LFGetSize(old_ptr);
118 memcpy(new_ptr, old_ptr, ((old_size < new_size) ? old_size : new_size));
119 LFFree(old_ptr);
120 return new_ptr;
121}
122
123extern "C" size_t malloc_usable_size(void* ptr) {
124 if (ptr == nullptr) {

Callers

nothing calls this directly

Calls 3

LFAllocFunction · 0.85
LFFreeFunction · 0.85
LFGetSizeFunction · 0.85

Tested by

no test coverage detected