| 1 | @node Obstacks,Licenses,Functions,Top
|
|---|
| 2 | @chapter Obstacks
|
|---|
| 3 | @cindex obstacks
|
|---|
| 4 |
|
|---|
| 5 | An @dfn{obstack} is a pool of memory containing a stack of objects. You
|
|---|
| 6 | can create any number of separate obstacks, and then allocate objects in
|
|---|
| 7 | specified obstacks. Within each obstack, the last object allocated must
|
|---|
| 8 | always be the first one freed, but distinct obstacks are independent of
|
|---|
| 9 | each other.
|
|---|
| 10 |
|
|---|
| 11 | Aside from this one constraint of order of freeing, obstacks are totally
|
|---|
| 12 | general: an obstack can contain any number of objects of any size. They
|
|---|
| 13 | are implemented with macros, so allocation is usually very fast as long as
|
|---|
| 14 | the objects are usually small. And the only space overhead per object is
|
|---|
| 15 | the padding needed to start each object on a suitable boundary.
|
|---|
| 16 |
|
|---|
| 17 | @menu
|
|---|
| 18 | * Creating Obstacks:: How to declare an obstack in your program.
|
|---|
| 19 | * Preparing for Obstacks:: Preparations needed before you can
|
|---|
| 20 | use obstacks.
|
|---|
| 21 | * Allocation in an Obstack:: Allocating objects in an obstack.
|
|---|
| 22 | * Freeing Obstack Objects:: Freeing objects in an obstack.
|
|---|
| 23 | * Obstack Functions:: The obstack functions are both
|
|---|
| 24 | functions and macros.
|
|---|
| 25 | * Growing Objects:: Making an object bigger by stages.
|
|---|
| 26 | * Extra Fast Growing:: Extra-high-efficiency (though more
|
|---|
| 27 | complicated) growing objects.
|
|---|
| 28 | * Status of an Obstack:: Inquiries about the status of an obstack.
|
|---|
| 29 | * Obstacks Data Alignment:: Controlling alignment of objects in obstacks.
|
|---|
| 30 | * Obstack Chunks:: How obstacks obtain and release chunks;
|
|---|
| 31 | efficiency considerations.
|
|---|
| 32 | * Summary of Obstacks::
|
|---|
| 33 | @end menu
|
|---|
| 34 |
|
|---|
| 35 | @node Creating Obstacks
|
|---|
| 36 | @section Creating Obstacks
|
|---|
| 37 |
|
|---|
| 38 | The utilities for manipulating obstacks are declared in the header
|
|---|
| 39 | file @file{obstack.h}.
|
|---|
| 40 | @pindex obstack.h
|
|---|
| 41 |
|
|---|
| 42 | @comment obstack.h
|
|---|
| 43 | @comment GNU
|
|---|
| 44 | @deftp {Data Type} {struct obstack}
|
|---|
| 45 | An obstack is represented by a data structure of type @code{struct
|
|---|
| 46 | obstack}. This structure has a small fixed size; it records the status
|
|---|
| 47 | of the obstack and how to find the space in which objects are allocated.
|
|---|
| 48 | It does not contain any of the objects themselves. You should not try
|
|---|
| 49 | to access the contents of the structure directly; use only the functions
|
|---|
|
|---|