diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-10-17 23:48:36 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-10-17 23:48:36 +0200 |
commit | 013df84b3c633f5dd990f7c9b4cd99f5c870ebcd (patch) | |
tree | bf579edd45156df5465831970f8121e6fd65957e /doc | |
parent | typo (diff) | |
download | slibc-013df84b3c633f5dd990f7c9b4cd99f5c870ebcd.tar.gz slibc-013df84b3c633f5dd990f7c9b4cd99f5c870ebcd.tar.bz2 slibc-013df84b3c633f5dd990f7c9b4cd99f5c870ebcd.tar.xz |
info: more on alloca
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | doc/info/chap/memory-allocation.texinfo | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/info/chap/memory-allocation.texinfo b/doc/info/chap/memory-allocation.texinfo index a9d3c7e..5107d3a 100644 --- a/doc/info/chap/memory-allocation.texinfo +++ b/doc/info/chap/memory-allocation.texinfo @@ -305,6 +305,10 @@ tries to access memory that could not be allocated, or, depending on the kernel's configuration, before it returns. +On typical kernels and kernel configurations, +@code{alloca} and @code{malloc} will handle memory +exhaustion identically. + Undefined behaviour may be invoked if @code{alloca} is called within a function call. The behaviour depends on the machine, the compiler, and @@ -314,6 +318,21 @@ optimisations. You should avoid code similar to strcpy(alloca((strlen(string) + 1) * sizeof(char)), string) @end example +@code{alloca} has its restricts --- limited lifetime, +cannot be explicitly deallocated, not growable, and +not shrinkable --- but it can also be advantageous +because: +@itemize +@item +Results in cleaner code because it is deallocated +automatically. +@item +It does not waste any space on metainformation +required for bookkeeping. +@item +Uses a faster memory allocation mechanism. +@end itemize + @node Basic memory allocation |