]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man3/alloca.3
rename.2: SEE ALSO: add rename(1)
[thirdparty/man-pages.git] / man3 / alloca.3
index ff7453d4c816213e62ce2ca1f3685fa1a5db01f7..9dc7695e8eb326e460874040aad2163e0ecbd15b 100644 (file)
 .\"     Various rewrites and additions (notes on longjmp() and SIGSEGV).
 .\"     Weaken warning against use of alloca() (as per Debian bug 461100).
 .\"
-.TH ALLOCA 3 2013-10-07 "GNU" "Linux Programmer's Manual"
+.TH ALLOCA 3 2019-03-06 "GNU" "Linux Programmer's Manual"
 .SH NAME
 alloca \- allocate memory that is automatically freed
 .SH SYNOPSIS
 .B #include <alloca.h>
-.sp
+.PP
 .BI "void *alloca(size_t " size );
 .SH DESCRIPTION
 The
@@ -63,13 +63,20 @@ The
 function returns a pointer to the beginning of the allocated space.
 If the allocation causes stack overflow, program behavior is undefined.
 .SH ATTRIBUTES
-.SS Multithreading (see pthreads(7))
-The
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lb lb lb
+l l l.
+Interface      Attribute       Value
+T{
 .BR alloca ()
-function is thread-safe.
+T}     Thread safety   MT-Safe
+.TE
 .SH CONFORMING TO
-This function is not in POSIX.1-2001.
-
+This function is not in POSIX.1.
+.PP
 There is evidence that the
 .BR alloca ()
 function appeared in 32V, PWB, PWB.2, 3BSD, and 4BSD.
@@ -90,7 +97,7 @@ it can also simplify memory deallocation in applications that use
 or
 .BR siglongjmp (3).
 Otherwise, its use is discouraged.
-
+.PP
 Because the space allocated by
 .BR alloca ()
 is allocated within the stack frame,
@@ -99,7 +106,14 @@ is jumped over by a call to
 .BR longjmp (3)
 or
 .BR siglongjmp (3).
-
+.PP
+The space allocated by
+.BR alloca ()
+is
+.I not
+automatically deallocated if the pointer that refers to it
+simply goes out of scope.
+.PP
 Do not attempt to
 .BR free (3)
 space allocated by
@@ -126,19 +140,21 @@ Otherwise, (without an \-ansi or \-std=c* option) the glibc version of
 includes
 .I <alloca.h>
 and that contains the lines:
-.nf
-
-    #ifdef  __GNUC__
-    #define alloca(size)   __builtin_alloca (size)
-    #endif
-
-.fi
+.PP
+.in +4n
+.EX
+#ifdef  __GNUC__
+#define alloca(size)   __builtin_alloca (size)
+#endif
+.EE
+.in
+.PP
 with messy consequences if one has a private version of this function.
-.LP
+.PP
 The fact that the code is inlined means that it is impossible
 to take the address of this function, or to change its behavior
 by linking with a different library.
-.LP
+.PP
 The inlined code often consists of a single instruction adjusting
 the stack pointer, and does not check for stack overflow.
 Thus, there is no NULL error return.
@@ -147,7 +163,7 @@ There is no error indication if the stack frame cannot be extended.
 (However, after a failed allocation, the program is likely to receive a
 .B SIGSEGV
 signal if it attempts to access the unallocated space.)
-
+.PP
 On many systems
 .BR alloca ()
 cannot be used inside the list of arguments of a function call, because