diff options
Diffstat (limited to 'static/freebsd/man3/alloca.3 3.html')
| -rw-r--r-- | static/freebsd/man3/alloca.3 3.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/static/freebsd/man3/alloca.3 3.html b/static/freebsd/man3/alloca.3 3.html new file mode 100644 index 00000000..ae0dd6bf --- /dev/null +++ b/static/freebsd/man3/alloca.3 3.html @@ -0,0 +1,84 @@ +<table class="head"> + <tr> + <td class="head-ltitle">ALLOCA(3)</td> + <td class="head-vol">Library Functions Manual</td> + <td class="head-rtitle">ALLOCA(3)</td> + </tr> +</table> +<div class="manual-text"> +<section class="Sh"> +<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1> +<p class="Pp"><code class="Nm">alloca</code> — <span class="Nd">memory + allocator</span></p> +</section> +<section class="Sh"> +<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1> +<p class="Pp"><code class="In">#include + <<a class="In">stdlib.h</a>></code></p> +<p class="Pp"><var class="Ft">void *</var> + <br/> + <code class="Fn">alloca</code>(<var class="Fa" style="white-space: nowrap;">size_t + size</var>);</p> +</section> +<section class="Sh"> +<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1> +<p class="Pp">The + <a class="permalink" href="#alloca"><code class="Fn" id="alloca">alloca</code></a>() + function or macro allocates <var class="Fa">size</var> bytes of space in the + stack frame of the caller. This temporary space is automatically freed on + return.</p> +</section> +<section class="Sh"> +<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN + VALUES</a></h1> +<p class="Pp"><code class="Fn">alloca</code>() returns a pointer to the + beginning of the allocated space.</p> +</section> +<section class="Sh"> +<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE + ALSO</a></h1> +<p class="Pp"><a class="Xr">brk(2)</a>, <a class="Xr">calloc(3)</a>, + <a class="Xr">getpagesize(3)</a>, <a class="Xr">malloc(3)</a>, + <a class="Xr">realloc(3)</a></p> +</section> +<section class="Sh"> +<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1> +<p class="Pp"><code class="Fn">alloca</code>() appeared in + <span class="Ux">Version 7 AT&T UNIX/32V</span>.</p> +</section> +<section class="Sh"> +<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1> +<p class="Pp"><code class="Fn">alloca</code>() is machine and compiler + dependent; its use is discouraged.</p> +<p class="Pp"><code class="Fn">alloca</code>() 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 + <code class="Fn">alloca</code>() cannot determine such an error. Avoid + <code class="Fn">alloca</code>() with large unbounded allocations.</p> +<p class="Pp">The use of C99 variable-length arrays and + <code class="Fn">alloca</code>() in the same function will cause the + lifetime of <code class="Fn">alloca</code>()'s storage to be limited to the + block containing the <code class="Fn">alloca</code>(). For example, in the + following snippet, <var class="Va">p</var>'s lifetime does not extend + outside of the block, whereas it would've if <var class="Va">vla</var> + hadn't been defined or had been defined as a fixed-length array:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>char *p; +{ + const int n = 100; + int vla[n]; + p = alloca(32); + strcpy(p, "Hello, world!"); + printf("Inside: %s\n", p); /* Valid. */ +} +printf("Outside: %s\n", p); /* Undefined. */</pre> +</div> +</section> +</div> +<table class="foot"> + <tr> + <td class="foot-date">February 19, 2026</td> + <td class="foot-os">FreeBSD 15.0</td> + </tr> +</table> |
