-
Notifications
You must be signed in to change notification settings - Fork 252
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
ab7bb52 to
06c665a
Compare
06c665a to
1b732db
Compare
5aff45d to
d7eb6b8
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]>
d7eb6b8 to
a3f05ac
Compare
See also: #1292 (comment)
Cc: @Karlson2k
Revisions:
v2
nparameter in MEMDUP(). I think we won't need it, as it will likely be1everywhere 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.?: 1trick. That's just for realloc(3).v2b
v3
v4
v4b
v4c
v4d
v5
s/MEMDUP/memdup_a/.v6
v6b