?? obstack.c
字號:
i >= 0; i--) ((COPYING_UNIT *)object_base)[i] = ((COPYING_UNIT *)h->object_base)[i]; /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, but that can cross a page boundary on a machine which does not do strict alignment for COPYING_UNITS. */ already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); } else already = 0; /* Copy remaining bytes one by one. */ for (i = already; i < obj_size; i++) object_base[i] = h->object_base[i]; /* If the object just copied was the only data in OLD_CHUNK, free that chunk and remove it from the chain. But not if that chunk might contain an empty object. */ if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) { new_chunk->prev = old_chunk->prev; CALL_FREEFUN (h, old_chunk); } h->object_base = object_base; h->next_free = h->object_base + obj_size; /* The new chunk certainly contains no empty object yet. */ h->maybe_empty_object = 0;}/* Return nonzero if object OBJ has been allocated from obstack H. This is here for debugging. If you use it in a program, you are probably losing. */# if defined __STDC__ && __STDC__/* Suppress -Wmissing-prototypes warning. We don't want to declare this in obstack.h because it is just for debugging. */int _obstack_allocated_p (struct obstack *h, POINTER obj);# endifint_obstack_allocated_p (h, obj) struct obstack *h; POINTER obj;{ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = (h)->chunk; /* We use >= rather than > since the object cannot be exactly at the beginning of the chunk but might be an empty object exactly at the end of an adjacent chunk. */ while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) { plp = lp->prev; lp = plp; } return lp != 0;}/* Free objects in obstack H, including OBJ and everything allocate more recently than OBJ. If OBJ is zero, free everything in H. */# undef obstack_free/* This function has two names with identical definitions. This is the first one, called from non-ANSI code. */void_obstack_free (h, obj) struct obstack *h; POINTER obj;{ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) { plp = lp->prev; CALL_FREEFUN (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ h->maybe_empty_object = 1; } if (lp) { h->object_base = h->next_free = (char *) (obj); h->chunk_limit = lp->limit; h->chunk = lp; } else if (obj != 0) /* obj is not in any of the chunks! */ abort ();}/* This function is used from ANSI code. */voidobstack_free (h, obj) struct obstack *h; POINTER obj;{ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) { plp = lp->prev; CALL_FREEFUN (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ h->maybe_empty_object = 1; } if (lp) { h->object_base = h->next_free = (char *) (obj); h->chunk_limit = lp->limit; h->chunk = lp; } else if (obj != 0) /* obj is not in any of the chunks! */ abort ();}int_obstack_memory_used (h) struct obstack *h;{ register struct _obstack_chunk* lp; register int nbytes = 0; for (lp = h->chunk; lp != 0; lp = lp->prev) { nbytes += lp->limit - (char *) lp; } return nbytes;}/* Define the error handler. */# ifndef _# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC# include <libintl.h># ifndef _# define _(Str) gettext (Str)# endif# else# define _(Str) (Str)# endif# endif# if defined _LIBC && defined USE_IN_LIBIO# include <libio/iolibio.h># define fputs(s, f) _IO_fputs (s, f)# endif# ifndef __attribute__/* This feature is available in gcc versions 2.5 and later. */# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)# define __attribute__(Spec) /* empty */# endif# endifstatic void__attribute__ ((noreturn))print_and_abort (){ /* Don't change any of these strings. Yes, it would be possible to add the newline to the string and use fputs or so. But this must not happen because the "memory exhausted" message appears in other places like this and the translation should be reused instead of creating a very similar string which requires a separate translation. */# if defined _LIBC && defined USE_IN_LIBIO if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s\n", _("memory exhausted")); else# endif fprintf (stderr, "%s\n", _("memory exhausted")); exit (obstack_exit_failure);}# if 0/* These are now turned off because the applications do not use it and it uses bcopy via obstack_grow, which causes trouble on sysV. *//* Now define the functional versions of the obstack macros. Define them to simply use the corresponding macros to do the job. */# if defined __STDC__ && __STDC__/* These function definitions do not work with non-ANSI preprocessors; they won't pass through the macro names in parentheses. *//* The function names appear in parentheses in order to prevent the macro-definitions of the names from being expanded there. */POINTER (obstack_base) (obstack) struct obstack *obstack;{ return obstack_base (obstack);}POINTER (obstack_next_free) (obstack) struct obstack *obstack;{ return obstack_next_free (obstack);}int (obstack_object_size) (obstack) struct obstack *obstack;{ return obstack_object_size (obstack);}int (obstack_room) (obstack) struct obstack *obstack;{ return obstack_room (obstack);}int (obstack_make_room) (obstack, length) struct obstack *obstack; int length;{ return obstack_make_room (obstack, length);}void (obstack_grow) (obstack, data, length) struct obstack *obstack; const POINTER data; int length;{ obstack_grow (obstack, data, length);}void (obstack_grow0) (obstack, data, length) struct obstack *obstack; const POINTER data; int length;{ obstack_grow0 (obstack, data, length);}void (obstack_1grow) (obstack, character) struct obstack *obstack; int character;{ obstack_1grow (obstack, character);}void (obstack_blank) (obstack, length) struct obstack *obstack; int length;{ obstack_blank (obstack, length);}void (obstack_1grow_fast) (obstack, character) struct obstack *obstack; int character;{ obstack_1grow_fast (obstack, character);}void (obstack_blank_fast) (obstack, length) struct obstack *obstack; int length;{ obstack_blank_fast (obstack, length);}POINTER (obstack_finish) (obstack) struct obstack *obstack;{ return obstack_finish (obstack);}POINTER (obstack_alloc) (obstack, length) struct obstack *obstack; int length;{ return obstack_alloc (obstack, length);}POINTER (obstack_copy) (obstack, address, length) struct obstack *obstack; const POINTER address; int length;{ return obstack_copy (obstack, address, length);}POINTER (obstack_copy0) (obstack, address, length) struct obstack *obstack; const POINTER address; int length;{ return obstack_copy0 (obstack, address, length);}# endif /* __STDC__ */# endif /* 0 */#endif /* !ELIDE_CODE */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -