summaryrefslogtreecommitdiff
path: root/Documentation/process
diff options
context:
space:
mode:
authorManuel Ebner <manuelebner@mailbox.org>2026-04-29 09:14:44 +0200
committerJonathan Corbet <corbet@lwn.net>2026-05-03 08:54:21 -0600
commit7c6d969d5349c40348276d5c301b2d200afa623d (patch)
tree14bcf8c7ae8a9e3afc2af500b7ee3e607f2d3f9b /Documentation/process
parente5ebf6278d06b55dadded317b92e351c03e05e6e (diff)
Documentation: adopt new coding style of type-aware kmalloc-family
Update the documentation to reflect new type-aware kmalloc-family as suggested in commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family") ptr = kmalloc(sizeof(*ptr), gfp); -> ptr = kmalloc_obj(*ptr, gfp); ptr = kmalloc(sizeof(struct some_obj_name), gfp); -> ptr = kmalloc_obj(*ptr, gfp); ptr = kzalloc(sizeof(*ptr), gfp); -> ptr = kzalloc_obj(*ptr, gfp); ptr = kmalloc_array(count, sizeof(*ptr), gfp); -> ptr = kmalloc_objs(*ptr, count, gfp); ptr = kcalloc(count, sizeof(*ptr), gfp); -> ptr = kzalloc_objs(*ptr, count, gfp); Signed-off-by: Manuel Ebner <manuelebner@mailbox.org> Acked-by: SeongJae Park <sj@kernel.org> Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20260429071445.309733-2-manuelebner@mailbox.org>
Diffstat (limited to 'Documentation/process')
-rw-r--r--Documentation/process/coding-style.rst8
1 files changed, 4 insertions, 4 deletions
diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index 35b381230f6e..a3bf75dc7c88 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -936,7 +936,7 @@ used.
---------------------
The kernel provides the following general purpose memory allocators:
-kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), and
+kmalloc(), kzalloc(), kmalloc_objs(), kzalloc_objs(), vmalloc(), and
vzalloc(). Please refer to the API documentation for further information
about them. :ref:`Documentation/core-api/memory-allocation.rst
<memory_allocation>`
@@ -945,7 +945,7 @@ The preferred form for passing a size of a struct is the following:
.. code-block:: c
- p = kmalloc(sizeof(*p), ...);
+ p = kmalloc_obj(*p, ...);
The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
@@ -959,13 +959,13 @@ The preferred form for allocating an array is the following:
.. code-block:: c
- p = kmalloc_array(n, sizeof(...), ...);
+ p = kmalloc_objs(*ptr, n, ...);
The preferred form for allocating a zeroed array is the following:
.. code-block:: c
- p = kcalloc(n, sizeof(...), ...);
+ p = kzalloc_objs(*ptr, n, ...);
Both forms check for overflow on the allocation size n * sizeof(...),
and return NULL if that occurred.