FastLED 3.10.6
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 183 of file allocator.h.

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

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

+ Here is the caller graph for this function: