# stack_alloc.h File Reference

Temporary memory allocation on stack. More...

## Defines
#define | ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
#define | PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
#define | PUSHS(stack, type) (ALIGN((stack),sizeof(long)),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type))))
#define | VARDECL(var) var
#define | ALLOC(var, size, type) var = PUSH(stack, size, type)

## Detailed Description

Temporary memory allocation on stack.

## Define Documentation

#define ALIGN | ( | stack,
|  | size |  | ) | ((stack) += ((size) - (long)(stack)) & ((size) - 1))

Aligns the stack to a 'size' boundary

Parameters:

  | stack | Stack
  | size | New size boundary

#define ALLOC | ( | var,
|  | size,
|  | type |  | ) | var = PUSH(stack, size, type)

Allocate 'size' elements of 'type' on stack

Parameters:

  | var | Name of variable to allocate
  | size | Number of elements
  | type | Type of element

#define PUSH | ( | stack,
|  | size,
|  | type |  | ) | (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))

Allocates 'size' elements of type 'type' on the stack

Parameters:

  | stack | Stack
  | size | Number of elements
  | type | Type of element

#define PUSHS | ( | stack,
|  | type |  | ) | (ALIGN((stack),sizeof(long)),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type))))

Allocates a struct stack

Parameters:

  | stack | Stack
  | type | Struct type

#define VARDECL | ( | var |  | ) | var

Declare variable on stack

Parameters:

  | var | Variable to declare