MCPcopy Create free account
hub / github.com/FastLED/FastLED / reallocate

Function reallocate

src/fl/stl/allocator.h:362–384  ·  view source on GitHub ↗

OPTIMIZED: reallocate() - in-place resize using fl::realloc() Returns the new pointer if successful, nullptr if not supported/failed The caller (fl::vector) handles fallback to allocate-copy-deallocate

Source from the content-addressed store, hash-verified

360 // Returns the new pointer if successful, nullptr if not supported/failed
361 // The caller (fl::vector) handles fallback to allocate-copy-deallocate
362 pointer reallocate(pointer ptr, fl::size old_count, fl::size new_count) FL_NOEXCEPT {
363 if (new_count == 0) {
364 if (ptr) {
365 deallocate(ptr, old_count);
366 }
367 return nullptr;
368 }
369
370 // Use fl::realloc() for in-place resize
371 void* result = fl::realloc(ptr, new_count * sizeof(T));
372 if (!result) {
373 return nullptr; // Realloc failed
374 }
375
376 T* new_ptr = static_cast<T*>(result);
377
378 // Zero-initialize any newly allocated memory
379 if (new_count > old_count) {
380 fl::memset(new_ptr + old_count, 0, (new_count - old_count) * sizeof(T));
381 }
382
383 return new_ptr;
384 }
385};
386
387template <typename T> class allocator_psram {

Callers

nothing calls this directly

Calls 3

deallocateFunction · 0.85
memsetFunction · 0.85
reallocFunction · 0.70

Tested by

no test coverage detected