You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could we merge nulling the pointer into cxplat_free_preemptible_work_item?
That is, Gianni asks about changing point 1 above, to take an [in,out] pointer to the pointer, and set it to null after freeing.
In #109, @nibanks also asks about changing point 2 above. There, Dave Thaler responded:
When we went through the decision process, we came to the opposite conclusion (ALL free apis should accept nullptr), for mainly the following reasons:
Consistency with the POSIX standard. This is the industry consensus on good API design, which is why free() is defined to accept a null ptr. Thus, programmers familiar with standard API conventions aren't surprised.
Minimizes number of code paths (reducing code complexity and increasing code coverage), since otherwise many places, instead of 1, have to test for null.
The first point applies to Gianni's question as well.
This discussion was converted from issue #112 on September 18, 2023 21:10.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Today, APIs that free memory follow the POSIX standard model for free(), etc., namely:
In microsoft/ebpf-for-windows#2783 (comment), @gtrevi asks:
That is, Gianni asks about changing point 1 above, to take an
[in,out]
pointer to the pointer, and set it to null after freeing.In #109, @nibanks also asks about changing point 2 above. There, Dave Thaler responded:
The first point applies to Gianni's question as well.
Beta Was this translation helpful? Give feedback.
All reactions