Move os_memdup into src/utils/allocs - #429
Merged
Merged
Conversation
Document that the implementation of `os_memdup` was adapted from commit dbdda355d0add3f7d96e3279321d3a63abfc4b32 in hostapd, see https://w1.fi/cgit/hostap/commit/?id=dbdda355d0add3f7d96e3279321d3a63abfc4b32
Codecov Report
@@ Coverage Diff @@
## main #429 +/- ##
=======================================
Coverage 53.09% 53.09%
=======================================
Files 144 144
Lines 19880 19880
=======================================
Hits 10555 10555
Misses 9325 9325
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Move `os_memdup` from `src/radius/common.h` into `src/utils/allocs.h`. This function should be with all the other memory allocation functions, so that we can give it a C23 [[nodiscard]] attribute, see https://en.cppreference.com/w/c/language/attributes/nodiscard (or GCC/Clang equivalent attribute, since we don't yet support C23).
aloisklink
force-pushed
the
refactor/move-os_memdup
branch
from
February 20, 2023 12:12
cda0828 to
918301c
Compare
mereacre
self-requested a review
February 20, 2023 16:27
mereacre
approved these changes
Feb 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move
os_memdupfromsrc/radius/common.hintosrc/utils/allocs.h.This function should be with all the other memory allocation functions, so that we can give it a C23
[[nodiscard]]attribute (or GCC/Clang equivalent attribute, since we don't yet support C23).This PR also documents that the implementation of
os_memdupwas adapted from commitdbdda35in hostapd.Kind of confusingly, there's actually two versions of the function in PR #380.
os_memdupinsrc/radius/common.h:edgesec/src/radius/common.h
Lines 179 to 189 in 666a609
sys_memdupinsrc/utils/allocs.h(this one was added in commit 24a8d46):edgesec/src/utils/allocs.h
Lines 32 to 42 in 666a609
I've decided to stick my version of this function into
src/utils/allocs.h, since @mereacre commited it later in 24a8d46.Plus, having it in
allocsmakes more sense, since it also makes it easier for us to add a[[nodiscard]]attribute to the function, so that the compiler throws an error if we don't do anything with the return value of the function.