is a stack
(data items) which is grown dynamically.
Obstack code typically provides C language macros which take care of memory allocation and management for you. Basically, obstacks are used as a form of memory management which can be more efficient and less difficult to implement than malloc/free in several situations.
For example, say one needs to set up a stack for handling data items whose numbers grow for a while and then reach a final form; such a stack could be defined in obstack.h.
The GNU C Library's info file summary of obstacks:
- An "obstack" is a pool of memory containing a stack of objects. You can create any number of separate obstacks, and then allocate objects in specified obstacks. Within each obstack, the last object allocated must always be the first one freed, but distinct obstacks are independent of each other.
- Aside from this one constraint of order of freeing, obstacks are totally general: an obstack can contain any number of objects of any size. They are implemented with macros, so allocation is usually very fast as long as the objects are usually small. And the only space overhead per object is the padding needed to start each object on a suitable boundary.