mirror of
https://github.com/mangosfour/server.git
synced 2025-12-25 22:37:04 +00:00
[10982] Optimize memory usage of Field class used in DB code. Should also slightly speedup server startup time.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
f56ae22ed9
commit
b89e531fee
3 changed files with 11 additions and 53 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue