-
Notifications
You must be signed in to change notification settings - Fork 251
Add and use memdup(), MEMDUP(), instead of its pattern #1296
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
base: master
Are you sure you want to change the base?
Conversation
f906dbd
to
f09d8ec
Compare
f09d8ec
to
d992542
Compare
d992542
to
5239d2b
Compare
I still recommend adding attribute |
See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute
|
I think by having this function declared I don't like using attributes for telling the compiler that it can optimize. That's error-prone. I prefer allowing it to see more of the code, so it can reason by itself. |
Then you do not need current |
The |
e6e4c80
to
903035d
Compare
903035d
to
ab7bb52
Compare
Signed-off-by: Alejandro Colomar <[email protected]>
This function already returned NULL on some errors. It didn't make any sense to exit(3) on allocation failure. Instead, just return NULL. Signed-off-by: Alejandro Colomar <[email protected]>
Cc: "Evgeny Grin (Karlson2k)" <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
ab7bb52
to
06c665a
Compare
See also: #1292 (comment)
Cc: @Karlson2k
Revisions:
v2
n
parameter in MEMDUP(). I think we won't need it, as it will likely be1
everywhere we might want to duplicate memory. The use of this API seems to be duplicating a pointer to structure that uses static storage in non-reentrant functions.?: 1
trick. That's just for realloc(3).v2b
v3
v4
v4b