]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
linuxkpi: Define `ZERO_OR_NULL_PTR()` in <linux/slab.h>
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>
Fri, 11 Nov 2022 20:03:25 +0000 (21:03 +0100)
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>
Fri, 11 Nov 2022 20:03:25 +0000 (21:03 +0100)
commit208d02fd5d165389aed0c2b60519cb6b0f5b89f9
treed0f90911bf82ca1ad4efb2c685bbef02d5ecf356
parent86a1c5d1294579d6787811a5d9cde2aad2567cd9
linuxkpi: Define `ZERO_OR_NULL_PTR()` in <linux/slab.h>

On Linux, the `kmalloc()` family of functions returns a special value if
the size of the allocation is zero. This macro verifies if the pointer
is NULL (the allocation failed) or the size is 0 (the allocation was not
performed AFAIU). This special value can be passed to `kfree()`.

On FreeBSD, our `malloc(9)` functions don't return a special value for
0-size allocations. Therefore we can simply compare the result against
NULL.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37367
sys/compat/linuxkpi/common/include/linux/slab.h