Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ alloca(3C) — IRIX 6.5.3f

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

malloc(3)

calloc(3)

free(3)



ALLOCA(3C)                                                          ALLOCA(3C)



NAME
     alloca - allocate dynamic space

SYNOPSIS
     #include <alloca.h>

     void *alloca (unsigned size);

DESCRIPTION
     alloca returns a pointer to size bytes of uninitialized local stack
     space.  Since the space is allocated using a built-in compiler function,
     the allocation is quite fast.  If zero is passed as size, alloca returns
     a valid pointer (unlike some versions of malloc, which consider a zero
     size to be an error).

     The #include <alloca.h> is required.

     Space allocated when a function foo calls alloca is freed automatically
     when foo returns.

     It is an error to call free with a pointer returned by alloca.

     Not all environments have alloca in their libraries, so code using it is
     not necessarily portable.  Reasonably portable public domain versions of
     this function are available from various sources on the Internet and the
     World Wide Web.

SEE ALSO
     malloc(3), calloc(3), free(3), /usr/include/alloca.h

DIAGNOSTICS
     In this implementation alloca cannot fail (though if size makes the
     process too large IRIX may kill the process).  Since alloca always
     returns a valid pointer, no diagnostics are possible.  Portability may be
     enhanced if the function calling alloca tests for a return value of 0 and
     handles 0 as an error.

CAVEATS
     Do not call alloca as an argument to another function, as in
     foo(alloca(20));.  Instead use, for example, cp = alloca(20); foo(cp);.















                                                                        Page 1



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026