C-Allocators: Mention reallocarray
for safe array allocation
Signed-off-by: Daiki Ueno <dueno@redhat.com>
This commit is contained in:
parent
4d3fbd6273
commit
e6baf3d2fb
1 changed files with 6 additions and 0 deletions
|
@ -118,6 +118,12 @@ to allocate an array of `n` elements of type
|
|||
greater than `((size_t) -1) / sizeof(T)`. See
|
||||
<<sect-Defensive_Coding-C-Arithmetic>>.
|
||||
|
||||
GNU libc provides a dedicated function `reallocarray` that allocates
|
||||
an array with those checks performed internally. However, care must
|
||||
be taken if portability is important: while the interface originated
|
||||
in OpenBSD and has been adopted in many other platforms, NetBSD
|
||||
exposes an incompatible behavior with the same interface.
|
||||
|
||||
[[sect-Defensive_Coding-C-Allocators-Custom]]
|
||||
=== Custom Memory Allocators
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue