diff --git a/dlls/mysqlx/threading.cpp b/dlls/mysqlx/threading.cpp index 86e6dd1c..d68c954c 100644 --- a/dlls/mysqlx/threading.cpp +++ b/dlls/mysqlx/threading.cpp @@ -330,6 +330,10 @@ AtomicResult::AtomicResult() { m_IsFree = true; m_CurRow = 0; + m_AllocFields = 0; + m_AllocRows = 0; + m_Rows = NULL; + m_Fields = NULL; } AtomicResult::~AtomicResult() @@ -338,6 +342,21 @@ AtomicResult::~AtomicResult() { FreeHandle(); } + + if (m_AllocFields) + { + delete [] m_Fields; + m_AllocFields = 0; + m_Fields = NULL; + } + if (m_AllocRows) + { + for (unsigned int i=0; iFieldCount(); m_RowCount = rs->RowCount(); - m_Fields.resize(m_FieldCount); - m_Rows.resize(m_RowCount); + if (m_RowCount > m_AllocRows) + { + /** allocate new array, zero it */ + stridx_t **newRows = new stridx_t *[m_RowCount]; + memset(newRows, 0, m_RowCount * sizeof(stridx_t *)); + /** if we have a new field count, just delete all the old stuff. */ + if (m_FieldCount > m_AllocFields) + { + for (unsigned int i=0; i m_AllocFields) + { + delete [] m_Fields; + m_Fields = new stridx_t[m_FieldCount]; + m_AllocFields = m_FieldCount; + } m_CurRow = 0; g_StringPool.StartHardLock(); @@ -482,7 +529,6 @@ void AtomicResult::CopyFrom(IResultSet *rs) while (!rs->IsDone()) { row = rs->GetRow(); - m_Rows[idx].resize(m_FieldCount); for (size_t i=0; iGetString(i)); rs->NextRow(); diff --git a/dlls/mysqlx/threading.h b/dlls/mysqlx/threading.h index 9a23aef0..25b084d7 100644 --- a/dlls/mysqlx/threading.h +++ b/dlls/mysqlx/threading.h @@ -25,11 +25,11 @@ public: void UnsetMutex(); bool IsThreadable(); public: - virtual stridx_t MakeString(const char *str); - virtual void FreeString(stridx_t idx); - virtual const char *GetString(stridx_t idx); - virtual void StartHardLock(); - virtual void StopHardLock(); + stridx_t MakeString(const char *str); + void FreeString(stridx_t idx); + const char *GetString(stridx_t idx); + void StartHardLock(); + void StopHardLock(); public: static const int NullString = -1; private: @@ -73,8 +73,10 @@ private: private: unsigned int m_RowCount; unsigned int m_FieldCount; - CVector m_Fields; - CVector > m_Rows; + unsigned int m_AllocFields; + unsigned int m_AllocRows; + stridx_t *m_Fields; + stridx_t **m_Rows; unsigned int m_CurRow; bool m_IsFree; };