Add simple in-line implementation of rdcarray::push_back

* Coverity can't figure out that a pointer being push_back'd isn't
  leaking, possibly due to the call to insert.
This commit is contained in:
baldurk
2017-11-09 12:41:17 +00:00
parent 2353421526
commit c49bb6fc7a
+9 -1
View File
@@ -158,7 +158,6 @@ public:
bool empty() const { return usedCount == 0; }
bool isEmpty() const { return usedCount == 0; }
void clear() { resize(0); }
void push_back(const T &el) { insert(size(), &el, 1); }
/////////////////////////////////////////////////////////////////
// managing elements and memory
@@ -231,6 +230,15 @@ public:
}
}
void push_back(const T &el)
{
// in-line implementation here instead of insert()
const size_t lastIdx = size();
reserve(size() + 1);
new(elems + lastIdx) T(el);
setUsedCount(usedCount + 1);
}
void insert(size_t offs, const T *el, size_t count)
{
const size_t oldSize = size();