MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / mallocForGrow

Method mallocForGrow

Sources/Shared/Containers/SmallVector.cpp:107–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 // Note: Moving this function into the header may cause performance regression.
106 template<class Size_T>
107 void* SmallVectorBase<Size_T>::mallocForGrow(void* firstEl, std::size_t minSize, std::size_t typeSize, std::size_t& newCapacity) {
108 newCapacity = getNewCapacity<Size_T>(minSize, typeSize, this->capacity());
109 // Even if capacity is not 0 now, if the vector was originally created with
110 // capacity 0, it's possible for the malloc to return FirstEl.
111 void* newElts = std::malloc(newCapacity * typeSize);
112 if (newElts == firstEl) {
113 newElts = replaceAllocation(newElts, typeSize, newCapacity);
114 }
115 return newElts;
116 }
117
118 // Note: Moving this function into the header may cause performance regression.
119 template<class Size_T>

Callers

nothing calls this directly

Calls 2

capacityMethod · 0.95
replaceAllocationFunction · 0.85

Tested by

no test coverage detected