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
clean up genalloc implementation #128
Merged
Merged
Conversation
This file contains 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
mbhangui
approved these changes
May 9, 2020
DerDakon
force-pushed
the
Dakon-genalloc-cleanup
branch
5 times, most recently
from
May 14, 2020 16:00
2cf90ea
to
aeab30e
Compare
leahneukirchen
approved these changes
May 18, 2020
schmonz
reviewed
May 18, 2020
This only moves the code blocks, but does not change any code at all.
Make sure calls to GEN_ALLOC_ready always follow GEN_ALLOC_readyplus.
Introduce an internal static helper function that does the common parts, which both functions can use.
While at it drop the register specification.
The names of the function parameters as well as the name of the local variable were taken from the macro arguments. Noone passed anything different than the default names there, and doing so doesn't make any sense anyway.
DerDakon
force-pushed
the
Dakon-genalloc-cleanup
branch
from
May 18, 2020 15:53
aeab30e
to
d831ab8
Compare
schmonz
requested changes
May 19, 2020
DerDakon
force-pushed
the
Dakon-genalloc-cleanup
branch
from
May 19, 2020 11:14
d831ab8
to
d2e607f
Compare
Save the new length in a local variable, and only change the value in the struct if allocation succeeds instead of changing it back on failure.
This was doing 2 assignments, a function call and a return on the same line. This had the additional slight bug that if the allocation failed it returned 0, but the allocation length in the struct passed in was already changed to the new value. This would not do any harm on subsequent calls as the pointer was still NULL and only that is checked.
alloc() is used in the generated code, so directly include it in this header instead of all the callers.
DerDakon
force-pushed
the
Dakon-genalloc-cleanup
branch
from
May 19, 2020 11:47
d2e607f
to
edf54c8
Compare
schmonz
approved these changes
May 19, 2020
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.
This code is best described as 90ies style function templates in C. This reduces the code duplication between the
*_readyplus
and*_ready
functions, which only differ slightly. Then the code is a bit de-obfuscated. I have used the additional unittest now in #102 to verify that things still behave the same.