]> git.proxmox.com Git - mirror_zfs.git/commit
Use __attribute__((malloc)) on memory allocation functions
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Fri, 26 May 2023 22:47:52 +0000 (18:47 -0400)
committerGitHub <noreply@github.com>
Fri, 26 May 2023 22:47:52 +0000 (15:47 -0700)
commit0f03a411615a797425de488eecfaaf63fc41acfe
tree8716d218bd3e42d453da04046671e3df371626ed
parent20494d47d22a60964274c73db3b22bc385eb9667
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
include/os/freebsd/spl/sys/kmem.h
include/os/linux/spl/sys/kmem.h
include/os/linux/spl/sys/vmem.h
include/sys/abd.h
lib/libspl/include/umem.h