if (isEmpty()) {
*this = ba;
} else if (!ba.isEmpty()) {
- if (d->ref != 1 || d->size + ba.d->size > d->alloc)
- reallocData(d->size + ba.d->size);
- memcpy(d->data + d->size, ba.d->data, ba.d->size);
- d->size += ba.d->size;
- d->data[d->size] = '\0';
+ append(ba.constData(), ba.size());
}
return *this;
}
if (str && len) {
if (d->ref != 1 || d->size + len > d->alloc)
reallocData(d->size + len);
- memcpy(d->data + d->size, str, len + 1); // include null terminator
+ memcpy(d->data + d->size, str, len);
d->size += len;
+ d->data[d->size] = '\0';
}
return *this;
}