void pstring_t<F>::sfree(pstr_t *s) { s->m_ref_count--; if (s->m_ref_count == 0 && s != &m_zero) { if (stk != nullptr) { unsigned sn= ((32 - countleadbits(s->len())) + 1) / 2; stk[sn].push(s); } else pfree_array(((char *)s)); //_mm_free(((char *)s)); } }
void pomemstream::vseek(const pos_type n) { m_pos = n; m_size = std::max(m_pos, m_size); if (m_size >= m_capacity) { while (m_size >= m_capacity) m_capacity *= 2; char *o = m_mem; m_mem = palloc_array<char>(m_capacity); if (m_mem == nullptr) { throw out_of_mem_e("pomemstream::vseek"); } std::copy(o, o + m_pos, m_mem); pfree_array(o); } }
void pomemstream::vseek(const pos_type n) { m_pos = n; m_size = std::max(m_pos, m_size); if (m_size >= m_capacity) { while (m_size >= m_capacity) m_capacity *= 2; char *o = m_mem; m_mem = palloc_array<char>(m_capacity); if (m_mem == nullptr) { set_flag(FLAG_ERROR); return; } memcpy(m_mem, o, m_pos); pfree_array(o); } }
void pomemstream::vwrite(const void *buf, const pos_type n) { if (m_pos + n >= m_capacity) { while (m_pos + n >= m_capacity) m_capacity *= 2; char *o = m_mem; m_mem = palloc_array<char>(m_capacity); if (m_mem == nullptr) { throw out_of_mem_e("pomemstream::vwrite"); } std::copy(o, o + m_pos, m_mem); pfree_array(o); } std::copy(static_cast<const char *>(buf), static_cast<const char *>(buf) + n, m_mem + m_pos); m_pos += n; m_size = std::max(m_pos, m_size); }
void pomemstream::vwrite(const void *buf, const unsigned n) { if (m_pos + n >= m_capacity) { while (m_pos + n >= m_capacity) m_capacity *= 2; char *o = m_mem; m_mem = palloc_array<char>(m_capacity); if (m_mem == nullptr) { set_flag(FLAG_ERROR); return; } memcpy(m_mem, o, m_pos); pfree_array(o); } memcpy(m_mem + m_pos, buf, n); m_pos += n; m_size = std::max(m_pos, m_size); }
pomemstream::~pomemstream() { pfree_array(m_mem); }