From e231c73051782185bd5d7c087fd37095626a0eb5 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Thu, 31 Jan 2008 11:03:55 +0000 Subject: [PATCH] First add an element, next increase count - makes class safer in MT world --- src/common/classes/array.h | 4 ++-- src/common/classes/vector.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/classes/array.h b/src/common/classes/array.h index 2501abe865..64acc77d0f 100644 --- a/src/common/classes/array.h +++ b/src/common/classes/array.h @@ -156,8 +156,8 @@ public: } size_t add(const T& item) { ensureCapacity(count + 1); - data[count++] = item; - return count; + data[count] = item; + return ++count; } // NOTE: remove method must be signal safe // This function may be called in AST. The function doesn't wait. diff --git a/src/common/classes/vector.h b/src/common/classes/vector.h index 89746f5d3c..6ebf1f1701 100644 --- a/src/common/classes/vector.h +++ b/src/common/classes/vector.h @@ -65,8 +65,8 @@ public: } size_t add(const T& item) { fb_assert(count < Capacity); - data[count++] = item; - return count; + data[count] = item; + return ++count; } T* remove(size_t index) { fb_assert(index < count);