source: trunk/binutils/libiberty/obstacks.texi@ 3204

Last change on this file since 3204 was 607, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 29.5 KB
Line 
1@node Obstacks,Licenses,Functions,Top
2@chapter Obstacks
3@cindex obstacks
4
5An @dfn{obstack} is a pool of memory containing a stack of objects. You
6can create any number of separate obstacks, and then allocate objects in
7specified obstacks. Within each obstack, the last object allocated must
8always be the first one freed, but distinct obstacks are independent of
9each other.
10
11Aside from this one constraint of order of freeing, obstacks are totally
12general: an obstack can contain any number of objects of any size. They
13are implemented with macros, so allocation is usually very fast as long as
14the objects are usually small. And the only space overhead per object is
15the 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
38The utilities for manipulating obstacks are declared in the header
39file @file{obstack.h}.
40@pindex obstack.h
41
42@comment obstack.h
43@comment GNU
44@deftp {Data Type} {struct obstack}
45An obstack is represented by a data structure of type @code{struct
46obstack}. This structure has a small fixed size; it records the status
47of the obstack and how to find the space in which objects are allocated.
48It does not contain any of the objects themselves. You should not try
49to access the contents of the structure directly; use only the functions