Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309707
b: refs/heads/master
c: 1583729
h: refs/heads/master
i:
  309705: 0820995
  309703: c2a8177
v: v3
  • Loading branch information
Xi Wang authored and Linus Torvalds committed Jun 1, 2012
1 parent dfbfccc commit 28abc10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1cefe28f95da307287a05a6a0c10213f01055e2a
refs/heads/master: 15837294d4ce717f69942f7366e99d4d1d3d9923
16 changes: 14 additions & 2 deletions trunk/Documentation/CodingStyle
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,9 @@ ones already enabled by DEBUG.
Chapter 14: Allocating memory

The kernel provides the following general purpose memory allocators:
kmalloc(), kzalloc(), kcalloc(), vmalloc(), and vzalloc(). Please refer to
the API documentation for further information about them.
kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), and
vzalloc(). Please refer to the API documentation for further information
about them.

The preferred form for passing a size of a struct is the following:

Expand All @@ -686,6 +687,17 @@ Casting the return value which is a void pointer is redundant. The conversion
from void pointer to any other pointer type is guaranteed by the C programming
language.

The preferred form for allocating an array is the following:

p = kmalloc_array(n, sizeof(...), ...);

The preferred form for allocating a zeroed array is the following:

p = kcalloc(n, sizeof(...), ...);

Both forms check for overflow on the allocation size n * sizeof(...),
and return NULL if that occurred.


Chapter 15: The inline disease

Expand Down

0 comments on commit 28abc10

Please sign in to comment.