HomeFreeBSD

Use __attribute__((malloc)) on memory allocation functions

Description

Use attribute((malloc)) on memory allocation functions

This informs the C compiler that pointers returned from these functions
do not alias other functions, which allows it to do better code
optimization and should make the compiled code smaller.

References:
https://stackoverflow.com/a/53654773
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute
https://clang.llvm.org/docs/AttributeReference.html#malloc

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14827

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on May 26 2023, 10:47 PM
GitHub <noreply@github.com>Committed on May 26 2023, 10:47 PM
Parents
rG20494d47d22a: ZTS: Add zpool_resilver_concurrent exception
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG0f03a411615a: Use __attribute__((malloc)) on memory allocation functions (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).May 26 2023, 10:47 PM