Commit 1c16b3d5 authored by Chris Packham's avatar Chris Packham Committed by Jonathan Corbet

docs/core-api: memory-allocation: mention size helpers

Mention struct_size(), array_size() and array3_size() in the same place
as kmalloc() and friends.
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 094ef1c9
...@@ -91,7 +91,8 @@ The most straightforward way to allocate memory is to use a function ...@@ -91,7 +91,8 @@ The most straightforward way to allocate memory is to use a function
from the kmalloc() family. And, to be on the safe side it's best to use from the kmalloc() family. And, to be on the safe side it's best to use
routines that set memory to zero, like kzalloc(). If you need to routines that set memory to zero, like kzalloc(). If you need to
allocate memory for an array, there are kmalloc_array() and kcalloc() allocate memory for an array, there are kmalloc_array() and kcalloc()
helpers. helpers. The helpers struct_size(), array_size() and array3_size() can
be used to safely calculate object sizes without overflowing.
The maximal size of a chunk that can be allocated with `kmalloc` is The maximal size of a chunk that can be allocated with `kmalloc` is
limited. The actual limit depends on the hardware and the kernel limited. The actual limit depends on the hardware and the kernel
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment