FastLED
3.10.6
Loading...
Searching...
No Matches
◆
reallocate()
template<typename T>
pointer
fl::allocator_realloc
< T >::reallocate
(
pointer
ptr
,
fl::size
old_count
,
fl::size
new_count
)
inline
Definition at line
363
of file
allocator.h
.
363
{
364
if
(
new_count
== 0) {
365
if
(
ptr
) {
366
deallocate
(
ptr
,
old_count
);
367
}
368
return
nullptr
;
369
}
370
371
// Use fl::realloc() for in-place resize
372
void
*
result
=
fl::realloc
(
ptr
,
new_count
*
sizeof
(
T
));
373
if
(!
result
) {
374
return
nullptr
;
// Realloc failed
375
}
376
377
T
*
new_ptr
=
static_cast<
T
*
>
(
result
);
378
379
// Zero-initialize any newly allocated memory
380
if
(
new_count
>
old_count
) {
381
fl::memset
(
new_ptr
+
old_count
, 0, (
new_count
-
old_count
) *
sizeof
(
T
));
382
}
383
384
return
new_ptr
;
385
}
fl::allocator_realloc::deallocate
void deallocate(T *p, fl::size n) FL_NO_EXCEPT
Definition
allocator.h:321
fl::allocator_realloc
Definition
allocator.h:271
fl::memset
void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
Definition
cstring.cpp.hpp:143
fl::realloc
void * realloc(void *ptr, size_t new_size)
Definition
malloc.cpp.hpp:26
fl
allocator_realloc
Generated on Sun Oct 4 2026 23:09:08 for FastLED by
1.13.2