FastLED 3.9.15
Loading...
Searching...
No Matches

◆ reallocate_impl() [2/2]

template<typename T>
pointer fl::allocator< T >::reallocate_impl ( pointer ptr,
fl::size old_count,
fl::size new_count,
fl::true_type  )
inlineprivate

Definition at line 182 of file allocator.h.

182 {
183 if (new_count == 0) {
184 if (ptr) {
186 }
187 return nullptr;
188 }
189
190 // Safe to use realloc() - type is trivially copyable
191 void* result = fl::realloc(ptr, new_count * sizeof(T));
192 if (!result) {
193 return nullptr; // Realloc failed
194 }
195
196 T* new_ptr = static_cast<T*>(result);
197
198 // Zero-initialize any newly allocated memory
199 if (new_count > old_count) {
200 fl::memset(new_ptr + old_count, 0, (new_count - old_count) * sizeof(T));
201 }
202
203 return new_ptr;
204 }
void deallocate(T *p, fl::size n) FL_NOEXCEPT
Definition allocator.h:232
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
void * realloc(void *ptr, size_t new_size)

Referenced by fl::allocator< U >::reallocate().

+ Here is the caller graph for this function: