Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Chris Packham <chris.packham@alliedtelesis.co.nz>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Chris Packham and committed by
Jonathan Corbet
1c16b3d5 094ef1c9

+2 -1
+2 -1
Documentation/core-api/memory-allocation.rst
··· 91 91 from the kmalloc() family. And, to be on the safe side it's best to use 92 92 routines that set memory to zero, like kzalloc(). If you need to 93 93 allocate memory for an array, there are kmalloc_array() and kcalloc() 94 - helpers. 94 + helpers. The helpers struct_size(), array_size() and array3_size() can 95 + be used to safely calculate object sizes without overflowing. 95 96 96 97 The maximal size of a chunk that can be allocated with `kmalloc` is 97 98 limited. The actual limit depends on the hardware and the kernel