⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 obstack.c

📁 linux平台中
💻 C
📖 第 1 页 / 共 2 页
字号:
     is sufficiently aligned.  */  if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)    {      for (i = obj_size / sizeof (COPYING_UNIT) - 1;	   i >= 0; i--)	((COPYING_UNIT *)new_chunk->contents)[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++)    new_chunk->contents[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 = new_chunk->contents;  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 _# ifdef HAVE_LIBINTL_H#  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)#endifstatic voidprint_and_abort (){  fputs (_("memory exhausted"), stderr);  fputc ('\n', stderr);  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, pointer, length)     struct obstack *obstack;     POINTER pointer;     int length;{  obstack_grow (obstack, pointer, length);}void (obstack_grow0) (obstack, pointer, length)     struct obstack *obstack;     POINTER pointer;     int length;{  obstack_grow0 (obstack, pointer, 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, pointer, length)     struct obstack *obstack;     POINTER pointer;     int length;{  return obstack_copy (obstack, pointer, length);}POINTER (obstack_copy0) (obstack, pointer, length)     struct obstack *obstack;     POINTER pointer;     int length;{  return obstack_copy0 (obstack, pointer, length);}#endif /* __STDC__ */#endif /* 0 */#endif	/* !ELIDE_CODE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -