FastLED
3.10.6
Loading...
Searching...
No Matches
◆
make_shared
template<typename T>
template<typename Y, typename... Args>
shared_ptr
< Y > make_shared
(
Args &&...
args
)
friend
Definition at line
414
of file
shared_ptr.h
.
414
{
415
// Allocate the control block's raw memory explicitly and null-check it
416
// BEFORE constructing. `new detail::InlinedControlBlock<T>()` cannot be
417
// trusted to skip construction on allocation failure: its custom
418
// operator new returns null under OOM, but the new-expression still
419
// runs the constructor on that null pointer — writing through address 0
420
// (EXCVADDR 0 crash) — and the old `if (control == nullptr)` guard was
421
// dead code because it ran only AFTER the null construction. This was
422
// the primary FastLED#3588 corruptor: under low free heap (which an
423
// active WiFi SoftAP creates, but so does any memory pressure) every
424
// make_shared<json_value> in the JSON-RPC build path faulted. Separate
425
// allocation from construction so the null check actually protects it.
426
void
*
mem
=
detail::InlinedControlBlock<T>::operator
new
(
427
sizeof
(
detail::InlinedControlBlock<T>
));
428
if
(
mem
==
nullptr
) {
429
return
shared_ptr<T>
();
// OOM — degrade to an empty shared_ptr
430
}
431
auto
*
control
=
::new
(
mem
)
detail::InlinedControlBlock<T>
();
// global placement new on valid memory
432
T
*
obj
=
control
->get_object();
433
new
(
obj
)
T
(
fl::forward<Args>
(
args
)...);
// Placement new
434
control
->object_constructed =
true
;
435
return
shared_ptr<T>
(
obj
,
control
,
detail::make_shared_tag
{});
436
}
fl::shared_ptr::shared_ptr
friend class shared_ptr
Definition
shared_ptr.h:391
fl::shared_ptr
Definition
shared_ptr.h:155
fl
shared_ptr
Generated on Sun Oct 4 2026 23:09:10 for FastLED by
1.13.2