CONTENTS | INDEX | PREV | NEXT
 alloca

 NAME
  alloca - allocate memory from the stack

 SYNOPSIS
  void *ptr = alloca(long bytes);

 FUNCTION
  alloca() comes from the UNIX world.  It allocates memory off the
  stack for use within a procedure.  The allocated memory is
  automatically freed when the subroutine returns.

  DO NOT USE ALLOCA() IF YOU CAN HELP IT.  alloca() is not easily
  portable across machines.

 NOTE
  When a low stack condition arises, alloca() will abort by printing
  an error message and calling abort();  alloca() does NOT currently
  try to allocate dynamic memory when it runs out of stack.

  Some implementations of alloca() use alloca(0) to free allocated
  stack.  This feature is NOT currently implemented in DICE's
  alloca() call.

 EXAMPLE
  #include <alloca.h>
  #include <stdio.h>

  main(ac, av)
  char *av[];
  {
      char *ptr;
      if (ac == 1) {
      puts("test string");
      exit(1);
      }
      ptr = alloca(strlen(av[1]) + 8);
      sprintf(ptr, "FOO.%s", av[1]);
      puts(ptr);
      return(0);
  }

 SEE ALSO
  setjmp, longjmp