From c49bb6fc7a29ed5a5810a0246c1f6768a8f84422 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 9 Nov 2017 12:41:17 +0000 Subject: [PATCH] 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. --- renderdoc/api/replay/basic_types.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/renderdoc/api/replay/basic_types.h b/renderdoc/api/replay/basic_types.h index c7f1897de..6ed6d6b86 100644 --- a/renderdoc/api/replay/basic_types.h +++ b/renderdoc/api/replay/basic_types.h @@ -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();