8000 scheduled function: replacing new by malloc needs to initialize complex members by d-a-v · Pull Request #6233 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

scheduled function: replacing new by malloc needs to initialize complex members #6233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
... only when malloc succeeds
  • Loading branch information
d-a-v committed Jun 26, 2019
commit 21b582d86e66777ca32df1188bc6c55bf68b1bf8
4 changes: 3 additions & 1 deletion cores/esp8266/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ static scheduled_fn_t* get_fn_unsafe ()
// calling malloc instead of new to avoid exception raising while in ISR
// construct complex members in place (never raises exceptions)
result = (scheduled_fn_t*)malloc(sizeof(scheduled_fn_t));
new (&result->mFunc) decltype(result->mFunc)();
if (result)
{
new (&result->mFunc) decltype(result->mFunc)();
++sCount;
}
}
return result;
}
Expand Down
0