diff --git a/src/shared/Database/Field.cpp b/src/shared/Database/Field.cpp index bbd6c7935..f70f7297f 100644 --- a/src/shared/Database/Field.cpp +++ b/src/shared/Database/Field.cpp @@ -16,50 +16,5 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "DatabaseEnv.h" +//#include "DatabaseEnv.h" -Field::Field() : -mValue(NULL), mType(DB_TYPE_UNKNOWN) -{ -} - -Field::Field(Field &f) -{ - const char *value; - - value = f.GetString(); - - if (value && (mValue = new char[strlen(value) + 1])) - strcpy(mValue, value); - else - mValue = NULL; - - mType = f.GetType(); -} - -Field::Field(const char *value, enum Field::DataTypes type) : -mType(type) -{ - if (value && (mValue = new char[strlen(value) + 1])) - strcpy(mValue, value); - else - mValue = NULL; -} - -Field::~Field() -{ - if(mValue) delete [] mValue; -} - -void Field::SetValue(const char *value) -{ - if(mValue) delete [] mValue; - - if (value) - { - mValue = new char[strlen(value) + 1]; - strcpy(mValue, value); - } - else - mValue = NULL; -} diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index c6d7f9108..073effb02 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -34,11 +34,10 @@ class Field DB_TYPE_BOOL = 0x04 }; - Field(); - Field(Field &f); - Field(const char *value, enum DataTypes type); + Field() : mValue(NULL), mType(DB_TYPE_UNKNOWN) {} + Field(const char *value, enum DataTypes type) : mType(type) { mValue = const_cast(value); } - ~Field(); + ~Field() {} enum DataTypes GetType() const { return mType; } bool IsNULL() const { return mValue == NULL; } @@ -68,10 +67,14 @@ class Field } void SetType(enum DataTypes type) { mType = type; } - - void SetValue(const char *value); + //no need for memory allocations to store resultset field strings + //all we need is to cache pointers returned by different DBMS APIs + void SetValue(const char *value) { mValue = const_cast(value); }; private: + Field(Field &f); + Field& operator=(const Field& ); + char *mValue; enum DataTypes mType; }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 02b8169a7..1111151f5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10981" + #define REVISION_NR "10982" #endif // __REVISION_NR_H__