alloca.3.patch   [plain text]


--- alloca.3.orig	2010-02-22 12:44:05.000000000 -0800
+++ alloca.3	2010-02-22 12:50:53.000000000 -0800
@@ -34,25 +34,25 @@
 .Sh NAME
 .Nm alloca
 .Nd memory allocator
-.Sh LIBRARY
-.Lb libc
 .Sh SYNOPSIS
+.In alloca.h
+or
+.br
 .In stdlib.h
 .Ft void *
 .Fn alloca "size_t size"
 .Sh DESCRIPTION
 The
 .Fn alloca
-function
+macro
 allocates
 .Fa size
 bytes of space in the stack frame of the caller.
 This temporary space is automatically freed on
 return.
 .Sh RETURN VALUES
-The
 .Fn alloca
-function returns a pointer to the beginning of the allocated space.
+returns a pointer to the beginning of the allocated space.
 .Sh SEE ALSO
 .Xr brk 2 ,
 .Xr calloc 3 ,
@@ -60,24 +60,20 @@ function returns a pointer to the beginn
 .Xr malloc 3 ,
 .Xr realloc 3
 .Sh HISTORY
-The
 .Fn alloca
-function appeared in
+appeared in
 .At 32v .
 .\" .Bx ?? .
 .\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd
 .\" The first man page (or link to a man page that I can find at the
 .\" moment is 4.3...
 .Sh BUGS
-The
 .Fn alloca
-function
 is machine and compiler dependent;
 its use is discouraged.
 .Pp
-The
 .Fn alloca
-function is slightly unsafe because it cannot ensure that the pointer
+is slightly unsafe because it cannot ensure that the pointer
 returned points to a valid and usable block of memory.
 The allocation made may exceed the bounds of the stack, or even go
 further into other objects in memory, and
@@ -86,3 +82,8 @@ cannot determine such an error.
 Avoid
 .Fn alloca
 with large unbounded allocations.
+.Pp
+The use of C99 variable-length arrays and
+.Fn alloca
+in the same function will cause the lifetime of alloca's storage to be limited to the block containing the
+.Fn alloca