PB_ASSOC_CLASS_T_DEC
void
PB_ASSOC_CLASS_C_DEC::
swap(PB_ASSOC_CLASS_C_DEC& r_other)
{
  PB_ASSOC_DBG_ONLY(assert_valid());
  PB_ASSOC_DBG_ONLY(r_other.assert_valid());

  std::swap(m_a_entries, r_other.m_a_entries);

  std::swap(m_num_e, r_other.m_num_e);

  std::swap(m_num_used_e, r_other.m_num_used_e);

  my_ranged_probe_fn_base::swap(r_other);

  my_hash_eq_fn_base::swap(r_other);

  my_resize_base::swap(r_other);

  PB_ASSOC_DBG_ONLY(my_cntnr_debug_base::swap(r_other));

  PB_ASSOC_DBG_ONLY(assert_valid());
  PB_ASSOC_DBG_ONLY(r_other.assert_valid());
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
  _GLIBCXX_DEBUG_ONLY(assert_valid());
  if (it.m_p_nd == base_type::m_p_head)
    return it;

  reverse_iterator ret_it = it;
  ++ret_it;
  erase_node(it.m_p_nd);
  _GLIBCXX_DEBUG_ONLY(assert_valid());
  return ret_it;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
clear()
{
  for (size_type i = 0; i < m_size; ++i)
    erase_at(m_a_entries, i, s_no_throw_copies_ind);

  __try
    {
      const size_type actual_size = resize_policy::get_new_size_for_arbitrary(0);

      entry_pointer a_entries = s_entry_allocator.allocate(actual_size);

      resize_policy::notify_arbitrary(actual_size);

      s_entry_allocator.deallocate(m_a_entries, m_actual_size);

      m_actual_size = actual_size;

      m_a_entries = a_entries;
    }
  __catch(...)
    { }

  m_size = 0;

  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_CLASS_C_DEC::
left_child_next_sibling_heap_() :
  m_p_root(NULL),
  m_size(0)
{
  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() :
  m_p_head(s_head_allocator.allocate(1)),
  m_size(0)
{
  initialize();
  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
示例#6
0
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
  make_binomial_heap();
  const size_type ersd = base_type::erase_if(pred);
  base_type::find_max();
  _GLIBCXX_DEBUG_ONLY(assert_valid();)
  return ersd;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap_() :
  m_size(0),
  m_actual_size(resize_policy::min_size),
  m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
  while (first_it != last_it)
    push(*(first_it++));

  _GLIBCXX_DEBUG_ONLY(assert_valid();)
    }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) :
  Cmp_Fn(r_cmp_fn),
  m_p_root(NULL),
  m_size(0)
{
  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
示例#10
0
文件: asestrbuf.cpp 项目: ahiguti/ase
void
ase_string_buffer::truncate(size_type len)
{
  if (len >= size()) {
    return;
  }
  buf_end = bufalloc + len;
  assert_valid();
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const e_access_traits& r_e_access_traits) :
  synth_e_access_traits(r_e_access_traits),
  m_p_head(s_head_allocator.allocate(1)),
  m_size(0)
{
  initialize();
  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
示例#12
0
文件: main.cpp 项目: CCJY/coliru
    void set_exception(std::exception_ptr ptr)
    {
        assert_valid();

        std::shared_ptr<void> scope_guard(nullptr, [&](void*){
            mImpl.reset();
        });

        mImpl->mPromise.set_exception(ptr);
    }
示例#13
0
文件: asestrbuf.cpp 项目: ahiguti/ase
void
ase_string_buffer::remove_front(size_type len)
{
  assert(len <= size());
  const size_type savesize = size() - len;
  if (savesize != 0) {
    ::memmove(bufalloc, bufalloc + len, savesize);
  }
  buf_end = bufalloc + savesize;
  assert_valid();
}
示例#14
0
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size)
{
#ifdef PB_DS_REGRESSION
  typename Allocator::group_throw_prob_adjustor adjust(m_num_e);
#endif 

  if (new_size == m_num_e)
    return;

  _GLIBCXX_DEBUG_ONLY(assert_valid();)
void
PB_DS_CLASS_C_DEC::
copy_from_range(It first_it, It last_it)
{
  while (first_it != last_it)
    {
      insert_value(*first_it, s_no_throw_copies_ind);
      ++first_it;
    }

  std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));

  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
示例#16
0
文件: asestrbuf.cpp 项目: ahiguti/ase
ase_string_buffer::ase_string_buffer(size_type initial_alloc_size)
  : bufalloc(0), buf_end(0), bufalloc_end(0)
{
  /* we use malloc/free instead of new/delete in order to make debugging
    easier */
  const size_t bufalloc_len = (initial_alloc_size > alloc_size_min)
    ? initial_alloc_size : alloc_size_min;
  bufalloc = static_cast<value_type *>(
    X_MALLOC(bufalloc_len * sizeof(value_type)));
  if (!bufalloc) {
    throw std::bad_alloc();
  }
  buf_end = bufalloc;
  bufalloc_end = bufalloc + bufalloc_len;
  assert_valid();
}
示例#17
0
文件: main.cpp 项目: CCJY/coliru
    void set_value(const T& t)
    {
        assert_valid();

        std::shared_ptr<void> scope_guard(nullptr, [&](void*){
            mImpl.reset();
        });

        mImpl->mPromise.set_value(t);
        for (auto& callback : mImpl->mCallbacks)
        {
            try {
                callback(mImpl->mSharedFuture);
            } catch (...) {
            }
        }
    }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
do_resize_if_needed_no_throw()
{
  if (!resize_base::is_resize_needed())
    return;

  try
    {
      resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
    }
  catch(...)
    { }

  _GLIBCXX_DEBUG_ONLY(assert_valid();)
}
示例#19
0
文件: asestrbuf.cpp 项目: ahiguti/ase
void
ase_string_buffer::reset(size_type initial_alloc_size)
{
  const size_t len = (initial_alloc_size > alloc_size_min)
    ? initial_alloc_size : alloc_size_min;
  if (len != alloc_size()) {
    value_type *p = static_cast<value_type *>(
      X_MALLOC(len * sizeof(value_type)));
    if (!p) {
      throw std::bad_alloc();
    }
    X_FREE(bufalloc);
    bufalloc = p;
    bufalloc_end = bufalloc + len;
  }
  buf_end = bufalloc;
  assert_valid();
}
示例#20
0
PB_ASSOC_CLASS_T_DEC
inline void
PB_ASSOC_CLASS_C_DEC::
do_resize_if_needed_no_throw()
{
  if (!my_resize_base::is_resize_needed())
    return;

  try
    {
      do
	do_resize(my_resize_base::get_new_size(m_num_e_p, m_num_used_e));
      while (my_resize_base::is_resize_needed());
    }
  catch(...)
    { }

  PB_ASSOC_DBG_ONLY(assert_valid();)
    }
示例#21
0
文件: syntax.cpp 项目: fritzo/pomagma
Structure::Structure() {
    POMAGMA_INFO("Initializing solver::Structure");

    // Initialize vectors for 1-based indexing.
    term_arity_.resize(1);
    less_arg_.resize(1);

    // Initialize atoms.
    new_term(TermArity::TOP);
    new_term(TermArity::BOT);
    new_term(TermArity::I);
    new_term(TermArity::K);
    new_term(TermArity::B);
    new_term(TermArity::C);
    new_term(TermArity::S);

    if (POMAGMA_DEBUG_LEVEL) {
        assert_valid();
    }
}
示例#22
0
文件: asestrbuf.cpp 项目: ahiguti/ase
ase_string_buffer::value_type *
ase_string_buffer::make_space(size_type len)
{
  if (buf_end + len <= bufalloc_end) {
    /* no need to extend */
    return buf_end;
  }
  const size_type buf_end_offset = buf_end - bufalloc;
  const size_type nalloclen = buf_end_offset + len;
  assert(nalloclen > 0);
  value_type *const nptr = static_cast<value_type *>(
    X_REALLOC(bufalloc, nalloclen * sizeof(value_type)));
  if (!nptr) {
    throw std::bad_alloc();
  }
  bufalloc = nptr;
  bufalloc_end = nptr + nalloclen;
  buf_end = nptr + buf_end_offset;
  assert_valid();
  return buf_end;
}
示例#23
0
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(0)
{
  copy_from_range(first_it, last_it);
  _GLIBCXX_DEBUG_ONLY(assert_valid(););
示例#24
0
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : m_p_l(0)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
示例#25
0
int main(int argc, char *argv[])
{
	/* 1  Some correct UTF-8 text */
	assert_valid("You should see the Greek word 'kosme':       \"κόσμε\"");

	/* 2  Boundary condition test cases */
	/* 2.1  First possible sequence of a certain length */
	assert_valid_len("2.1.1  1 byte  (U-00000000):        \"\0\"", 39);
	assert_valid("2.1.2  2 bytes (U-00000080):        \"€\"");
	assert_valid("2.1.3  3 bytes (U-00000800):        \"ࠀ\"");
	assert_valid("2.1.4  4 bytes (U-00010000):        \"𐀀\"");

	/* 2.2  Last possible sequence of a certain length */

	assert_valid("2.2.1  1 byte  (U-0000007F):        \"\"");
	assert_valid("2.2.2  2 bytes (U-000007FF):        \"߿\"");
	assert_valid("2.2.3  3 bytes (U-0000FFFF):        \"￿\"");
	// FIXME assert_valid("2.2.4  4 bytes (U-001FFFFF):        \"����\"");

	/* 2.3  Other boundary conditions */

	assert_valid("2.3.1  U-0000D7FF = ed 9f bf = \"퟿\"");
	assert_valid("2.3.2  U-0000E000 = ee 80 80 = \"\"");
	assert_valid("2.3.3  U-0000FFFD = ef bf bd = \"�\"");
	assert_valid("2.3.4  U-0010FFFF = f4 8f bf bf = \"􏿿\"");
	/* This used to be valid in pre-2003 utf-8 */
	assert_invalid("2.3.5  U-00110000 = f4 90 80 80 = \"����\"");

	/* 3  Malformed sequences */
	/* 3.1  Unexpected continuation bytes */
	assert_invalid("3.1.1  First continuation byte 0x80: \"�\"");
	assert_invalid("3.1.2  Last  continuation byte 0xbf: \"�\"");
	assert_invalid("3.1.3  2 continuation bytes: \"��\"");
	assert_invalid("3.1.4  3 continuation bytes: \"���\"");
	assert_invalid("3.1.5  4 continuation bytes: \"����\"");
	assert_invalid("3.1.6  5 continuation bytes: \"�����\"");
	assert_invalid("3.1.7  6 continuation bytes: \"������\"");
	assert_invalid("3.1.8  7 continuation bytes: \"�������\"");

	/* 3.1.9  Sequence of all 64 possible continuation bytes (0x80-0xbf): */
	assert_invalid("����������������");
    assert_invalid("����������������");
    assert_invalid("����������������");
    assert_invalid("����������������\"");

	/* 3.2  Lonely start characters */

	/* 3.2.1  All 32 first bytes of 2-byte sequences (0xc0-0xdf),
       each followed by a space character: */
	assert_invalid("\"� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � \"");

	/* 3.2.2  All 16 first bytes of 3-byte sequences (0xe0-0xef),
       each followed by a space character: */
	assert_invalid("\"� � � � � � � � � � � � � � � � \"");

	/* 3.2.3  All 8 first bytes of 4-byte sequences (0xf0-0xf7),
       each followed by a space character: */
	assert_invalid("\"� � � � � � � � \"");

	/* 3.2.4  All 4 first bytes of 5-byte sequences (0xf8-0xfb),
       each followed by a space character: */
	assert_invalid("\"� � � � \"");

	/* 3.2.5  All 2 first bytes of 6-byte sequences (0xfc-0xfd),
       each followed by a space character: */
	assert_invalid("\"� � \"");

	/* 3.3  Sequences with last continuation byte missing

	All bytes of an incomplete sequence should be signalled as a single
	malformed sequence, i.e., you should see only a single replacement
	character in each of the next 10 tests. (Characters as in section 2) */

	assert_invalid("3.3.1  2-byte sequence with last byte missing (U+0000):     \"�\"");
	assert_invalid("3.3.2  3-byte sequence with last byte missing (U+0000):     \"��\"");
	assert_invalid("3.3.3  4-byte sequence with last byte missing (U+0000):     \"���\"");
	assert_invalid("3.3.4  5-byte sequence with last byte missing (U+0000):     \"����\"");
	assert_invalid("3.3.5  6-byte sequence with last byte missing (U+0000):     \"�����\"");
	assert_invalid("3.3.6  2-byte sequence with last byte missing (U-000007FF): \"�\"");
	assert_invalid("3.3.7  3-byte sequence with last byte missing (U-0000FFFF): \"�\"");
	assert_invalid("3.3.8  4-byte sequence with last byte missing (U-001FFFFF): \"���\"");
	assert_invalid("3.3.9  5-byte sequence with last byte missing (U-03FFFFFF): \"����\"");
	assert_invalid("3.3.10 6-byte sequence with last byte missing (U-7FFFFFFF): \"�����\"");

	/* 3.4  Concatenation of incomplete sequences

		All the 10 sequences of 3.3 concatenated, you should see 10 malformed
		sequences being signalled:*/

	assert_invalid("\"�����������������������������\"");

	/* 3.5  Impossible bytes

		The following two bytes cannot appear in a correct UTF-8 string */

	assert_invalid("3.5.1  fe = \"�\"");
	assert_invalid("3.5.2  ff = \"�\"");
	assert_invalid("3.5.3  fe fe ff ff = \"����\"");

	/* 4  Overlong sequences

		The following sequences are not malformed according to the letter of
		the Unicode 2.0 standard. However, they are longer then necessary and
		a correct UTF-8 encoder is not allowed to produce them. A "safe UTF-8
		decoder" should reject them just like malformed sequences for two
		reasons: (1) It helps to debug applications if overlong sequences are
		not treated as valid representations of characters, because this helps
		to spot problems more quickly. (2) Overlong sequences provide
		alternative representations of characters, that could maliciously be
		used to bypass filters that check only for ASCII characters. For
		instance, a 2-byte encoded line feed (LF) would not be caught by a
		line counter that counts only 0x0a bytes, but it would still be
		processed as a line feed by an unsafe UTF-8 decoder later in the
		pipeline. From a security point of view, ASCII compatibility of UTF-8
		sequences means also, that ASCII characters are *only* allowed to be
		represented by ASCII bytes in the range 0x00-0x7f. To ensure this
		aspect of ASCII compatibility, use only "safe UTF-8 decoders" that
		reject overlong UTF-8 sequences for which a shorter encoding exists. */

	/* 4.1  Examples of an overlong ASCII character

		With a safe UTF-8 decoder, all of the following five overlong
		representations of the ASCII character slash ("/") should be rejected
		like a malformed UTF-8 sequence, for instance by substituting it with
		a replacement character. If you see a slash below, you do not have a
		safe UTF-8 decoder! */

	assert_invalid("4.1.1 U+002F = c0 af             = \"��\"");
	assert_invalid("4.1.2 U+002F = e0 80 af          = \"���\"");
	assert_invalid("4.1.3 U+002F = f0 80 80 af       = \"����\"");
	assert_invalid("4.1.4 U+002F = f8 80 80 80 af    = \"�����\"");
	assert_invalid("4.1.5 U+002F = fc 80 80 80 80 af = \"������\"");

	/* 4.2  Maximum overlong sequences

		Below you see the highest Unicode value that is still resulting in an
		overlong sequence if represented with the given number of bytes. This
		is a boundary test for safe UTF-8 decoders. All five characters should
		be rejected like malformed UTF-8 sequences. */

	assert_invalid("4.2.1  U-0000007F = c1 bf             = \"��\"");
	assert_invalid("4.2.2  U-000007FF = e0 9f bf          = \"���\"");
	assert_invalid("4.2.3  U-0000FFFF = f0 8f bf bf       = \"����\"");
	assert_invalid("4.2.4  U-001FFFFF = f8 87 bf bf bf    = \"�����\"");
	assert_invalid("4.2.5  U-03FFFFFF = fc 83 bf bf bf bf = \"������\"");

	/* 4.3  Overlong representation of the NUL character

		The following five sequences should also be rejected like malformed
		UTF-8 sequences and should not be treated like the ASCII NUL
		character. */

	assert_invalid("4.3.1  U+0000 = c0 80             = \"��\"");
	assert_invalid("4.3.2  U+0000 = e0 80 80          = \"���\"");
	assert_invalid("4.3.3  U+0000 = f0 80 80 80       = \"����\"");
	assert_invalid("4.3.4  U+0000 = f8 80 80 80 80    = \"�����\"");
	assert_invalid("4.3.5  U+0000 = fc 80 80 80 80 80 = \"������\"");

	/* 5  Illegal code positions

		The following UTF-8 sequences should be rejected like malformed
		sequences, because they never represent valid ISO 10646 characters and
		a UTF-8 decoder that accepts them might introduce security problems
		comparable to overlong UTF-8 sequences. */

	/* 5.1 Single UTF-16 surrogates */

	assert_invalid("5.1.1  U+D800 = ed a0 80 = \"�\"");
	assert_invalid("5.1.2  U+DB7F = ed ad bf = \"�\"");
	assert_invalid("5.1.3  U+DB80 = ed ae 80 = \"�\"");
	assert_invalid("5.1.4  U+DBFF = ed af bf = \"�\"");
	assert_invalid("5.1.5  U+DC00 = ed b0 80 = \"�\"");
	assert_invalid("5.1.6  U+DF80 = ed be 80 = \"�\"");
	assert_invalid("5.1.7  U+DFFF = ed bf bf = \"�\"");

	/* 5.2 Paired UTF-16 surrogates */

	assert_invalid("5.2.1  U+D800 U+DC00 = ed a0 80 ed b0 80 = \"��\"");
	assert_invalid("5.2.2  U+D800 U+DFFF = ed a0 80 ed bf bf = \"��\"");
	assert_invalid("5.2.3  U+DB7F U+DC00 = ed ad bf ed b0 80 = \"��\"");
	assert_invalid("5.2.4  U+DB7F U+DFFF = ed ad bf ed bf bf = \"��\"");
	assert_invalid("5.2.5  U+DB80 U+DC00 = ed ae 80 ed b0 80 = \"��\"");
	assert_invalid("5.2.6  U+DB80 U+DFFF = ed ae 80 ed bf bf = \"��\"");
	assert_invalid("5.2.7  U+DBFF U+DC00 = ed af bf ed b0 80 = \"��\"");
	assert_invalid("5.2.8  U+DBFF U+DFFF = ed af bf ed bf bf = \"��\"");

	/* 5.3 Noncharacter code positions

		The following "noncharacters" are "reserved for internal use" by
		applications, and according to older versions of the Unicode Standard
		"should never be interchanged". Unicode Corrigendum #9 dropped the
		latter restriction. Nevertheless, their presence in incoming UTF-8 data
		can remain a potential security risk, depending on what use is made of
		these codes subsequently. Examples of such internal use:

		- Some file APIs with 16-bit characters may use the integer value -1
		= U+FFFF to signal an end-of-file (EOF) or error condition.

		- In some UTF-16 receivers, code point U+FFFE might trigger a
		byte-swap operation (to convert between UTF-16LE and UTF-16BE).

		With such internal use of noncharacters, it may be desirable and safer
		to block those code points in UTF-8 decoders, as they should never
		occur legitimately in incoming UTF-8 data, and could trigger unsafe
		behaviour in subsequent processing.

		Particularly problematic noncharacters in 16-bit applications: */

	assert_valid("5.3.1  U+FFFE = ef bf be = \"￾\"");
	assert_valid("5.3.2  U+FFFF = ef bf bf = \"￿\"");

	/* Other noncharacters: */

	assert_valid("5.3.3  U+FDD0 .. U+FDEF = \"﷐﷑﷒﷓﷔﷕﷖﷗﷘﷙﷚﷛﷜﷝﷞﷟﷠﷡﷢﷣﷤﷥﷦﷧﷨﷩﷪﷫﷬﷭﷮﷯\"");

	/* 5.3.4  U+nFFFE U+nFFFF (for n = 1..10) */

	assert_valid("\"🿾🿿𯿾𯿿𿿾𿿿񏿾񏿿񟿾񟿿񯿾񯿿񿿾񿿿򏿾򏿿򟿾򟿿򯿾򯿿򿿾򿿿󏿾󏿿󟿾󟿿󯿾󯿿󿿾󿿿􏿾􏿿\"");


	return 0;
}
示例#26
0
文件: rc.hpp 项目: 12019/SDKs
 PB_DS_CLASS_C_DEC::
 rc() : m_over_top(0)
 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
示例#27
0
文件: main.cpp 项目: CCJY/coliru
 void add_callback(F&& f)
 {
     assert_valid();
     mImpl->mCallbacks.push_back(std::forward<F>(f));
 }
示例#28
0
文件: rc.hpp 项目: 12019/SDKs
 PB_DS_CLASS_T_DEC
 PB_DS_CLASS_C_DEC::
 rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0)
 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
示例#29
0
文件: main.cpp 项目: CCJY/coliru
 std::shared_future<T> get_future()
 {
     assert_valid();
     return mImpl->mSharedFuture;
 }
示例#30
0
文件: syntax.cpp 项目: fritzo/pomagma
Structure::~Structure() {
    if (POMAGMA_DEBUG_LEVEL) {
        assert_valid();
    }
}