Ejemplo n.º 1
0
void StringBuffer::absorb(StringBuffer &buf) {
  if (empty()) {
    TAINT_OBSERVER_REGISTER_ACCESSED(buf.getTaintDataRefConst());
    TAINT_OBSERVER_REGISTER_MUTATED(m_taint_data, dataIgnoreTaint());

    StringData* str = m_str;

    m_str = buf.m_str;
    m_buffer = buf.m_buffer;
    m_len = buf.m_len;
    m_cap = buf.m_cap;

    buf.m_str = str;
    if (str) {
      buf.m_buffer = (char*)str->data();
      buf.m_len = str->size();
      buf.m_cap = str->capacity();
    } else {
      buf.m_buffer = 0;
      buf.m_len = 0;
      buf.m_cap = 0;
    }
    buf.reset();
  } else {
    // REGISTER_ACCESSED()/REGISTER_MUTATED() are called by append()/detach()
    append(buf.detach());
  }
}
Ejemplo n.º 2
0
void StringBuffer::absorb(StringBuffer &buf) {
  if (empty()) {
    TAINT_OBSERVER_REGISTER_ACCESSED(buf.getTaintDataRefConst());
    TAINT_OBSERVER_REGISTER_MUTATED(m_taint_data);

    char *buffer = m_buffer;
    int size = m_size;

    m_buffer = buf.m_buffer;
    m_size = buf.m_size;
    m_pos = buf.m_pos;

    buf.m_buffer = buffer;
    buf.m_size = size;
    buf.reset();
  } else {
    append(buf.detach());
  }
}