123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- #include <obstack.h>
- void
- _obstack_begin (h, chunkfun)
- struct obstack *h;
- int (*chunkfun) ();
- {
- register _Ll* chunk;
- chunk = h->chunk =
- (_Ll*) (*chunkfun) (h->chunk_size);
- h->next_free = h->object_base = chunk->obstack_l_0;
- h->chunk_limit = chunk->obstack_l_limit
- = (char *) chunk + h->chunk_size;
- chunk->obstack_l_prev = 0;
- }
- void
- _obstack_newchunk (h, chunkfun, length)
- struct obstack *h;
- int (*chunkfun) ();
- int length;
- {
- register _Ll* old_chunk = h->chunk;
- register _Ll* new_chunk;
- register long new_size;
- register int obj_size = h->next_free - h->object_base;
-
- new_size = (obj_size + length) << 1;
- if (new_size < h->chunk_size)
- new_size = h->chunk_size;
-
- new_chunk = h->chunk = (_Ll*) (*chunkfun) (new_size);
- new_chunk->obstack_l_prev = old_chunk;
- new_chunk->obstack_l_limit = h->chunk_limit = (char *) new_chunk + new_size;
-
- bcopy (h->object_base, new_chunk->obstack_l_0, obj_size);
- h->object_base = new_chunk->obstack_l_0;
- h->next_free = h->object_base + obj_size;
- };
- void
- _obstack_free (h, freechunkfun, obj)
- struct obstack *h;
- void (*freechunkfun) ();
- char *obj;
- {
- register _Ll* lp;
- register _Ll* plp;
- lp = (h)->chunk;
- while (lp != 0 && ((char *)lp > obj || (lp)->obstack_l_limit < obj))
- {
- plp = lp -> obstack_l_prev;
- (*freechunkfun) (lp);
- lp = plp;
- }
- if (lp)
- {
- (h)->object_base = (h)->next_free = (char *)(obj);
- (h)->chunk_limit = lp->obstack_l_limit;
- (h)->chunk = lp;
- }
- else if (obj != 0)
-
- abort ();
- }
|