Commit 0a05caf2 authored by unknown's avatar unknown

- Fix memory leak

modified:
  storage/connect/connect.cc
  
- GCC requires template<> headers

modified:
  storage/connect/value.cpp
parent bf6c3f51
...@@ -82,6 +82,7 @@ PGLOBAL CntExit(PGLOBAL g) ...@@ -82,6 +82,7 @@ PGLOBAL CntExit(PGLOBAL g)
} // endif } // endif
free(dup); free(dup);
free(g->Activityp);
g= NULL; g= NULL;
} // endif g } // endif g
......
...@@ -508,6 +508,7 @@ int TYPVAL<TYPE>::GetValLen(void) ...@@ -508,6 +508,7 @@ int TYPVAL<TYPE>::GetValLen(void)
return sprintf(c, Fmt, Tval); return sprintf(c, Fmt, Tval);
} // end of GetValLen } // end of GetValLen
template <>
int TYPVAL<double>::GetValLen(void) int TYPVAL<double>::GetValLen(void)
{ {
char c[32]; char c[32];
...@@ -534,15 +535,19 @@ bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype) ...@@ -534,15 +535,19 @@ bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype)
return false; return false;
} // end of SetValue } // end of SetValue
template <>
short TYPVAL<short>::GetTypedValue(PVAL valp) short TYPVAL<short>::GetTypedValue(PVAL valp)
{return valp->GetShortValue();} {return valp->GetShortValue();}
template <>
int TYPVAL<int>::GetTypedValue(PVAL valp) int TYPVAL<int>::GetTypedValue(PVAL valp)
{return valp->GetIntValue();} {return valp->GetIntValue();}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PVAL valp) longlong TYPVAL<longlong>::GetTypedValue(PVAL valp)
{return valp->GetBigintValue();} {return valp->GetBigintValue();}
template <>
double TYPVAL<double>::GetTypedValue(PVAL valp) double TYPVAL<double>::GetTypedValue(PVAL valp)
{return valp->GetFloatValue();} {return valp->GetFloatValue();}
...@@ -587,6 +592,7 @@ void TYPVAL<TYPE>::SetValue_char(char *p, int n) ...@@ -587,6 +592,7 @@ void TYPVAL<TYPE>::SetValue_char(char *p, int n)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
template <>
void TYPVAL<double>::SetValue_char(char *p, int n) void TYPVAL<double>::SetValue_char(char *p, int n)
{ {
char *p2, buf[32]; char *p2, buf[32];
...@@ -614,9 +620,13 @@ void TYPVAL<TYPE>::SetValue_psz(PSZ s) ...@@ -614,9 +620,13 @@ void TYPVAL<TYPE>::SetValue_psz(PSZ s)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
template <>
int TYPVAL<int>::GetTypedValue(PSZ s) {return atol(s);} int TYPVAL<int>::GetTypedValue(PSZ s) {return atol(s);}
template <>
short TYPVAL<short>::GetTypedValue(PSZ s) {return (short)atoi(s);} short TYPVAL<short>::GetTypedValue(PSZ s) {return (short)atoi(s);}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PSZ s) {return atoll(s);} longlong TYPVAL<longlong>::GetTypedValue(PSZ s) {return atoll(s);}
template <>
double TYPVAL<double>::GetTypedValue(PSZ s) {return atof(s);} double TYPVAL<double>::GetTypedValue(PSZ s) {return atof(s);}
...@@ -630,15 +640,19 @@ void TYPVAL<TYPE>::SetValue_pvblk(PVBLK blk, int n) ...@@ -630,15 +640,19 @@ void TYPVAL<TYPE>::SetValue_pvblk(PVBLK blk, int n)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
template <>
int TYPVAL<int>::GetTypedValue(PVBLK blk, int n) int TYPVAL<int>::GetTypedValue(PVBLK blk, int n)
{return blk->GetIntValue(n);} {return blk->GetIntValue(n);}
template <>
short TYPVAL<short>::GetTypedValue(PVBLK blk, int n) short TYPVAL<short>::GetTypedValue(PVBLK blk, int n)
{return blk->GetShortValue(n);} {return blk->GetShortValue(n);}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PVBLK blk, int n) longlong TYPVAL<longlong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetBigintValue(n);} {return blk->GetBigintValue(n);}
template <>
double TYPVAL<double>::GetTypedValue(PVBLK blk, int n) double TYPVAL<double>::GetTypedValue(PVBLK blk, int n)
{return blk->GetFloatValue(n);} {return blk->GetFloatValue(n);}
...@@ -687,6 +701,7 @@ char *TYPVAL<TYPE>::ShowValue(char *buf, int len) ...@@ -687,6 +701,7 @@ char *TYPVAL<TYPE>::ShowValue(char *buf, int len)
return buf; return buf;
} // end of ShowValue } // end of ShowValue
template <>
char *TYPVAL<double>::ShowValue(char *buf, int len) char *TYPVAL<double>::ShowValue(char *buf, int len)
{ {
// TODO: use snprintf to avoid possible overflow // TODO: use snprintf to avoid possible overflow
...@@ -704,6 +719,7 @@ char *TYPVAL<TYPE>::GetCharString(char *p) ...@@ -704,6 +719,7 @@ char *TYPVAL<TYPE>::GetCharString(char *p)
return p; return p;
} // end of GetCharString } // end of GetCharString
template <>
char *TYPVAL<double>::GetCharString(char *p) char *TYPVAL<double>::GetCharString(char *p)
{ {
sprintf(p, Fmt, Prec, Tval); sprintf(p, Fmt, Prec, Tval);
...@@ -1173,7 +1189,7 @@ bool DTVAL::SetFormat(PGLOBAL g, PVAL valp) ...@@ -1173,7 +1189,7 @@ bool DTVAL::SetFormat(PGLOBAL g, PVAL valp)
/***********************************************************************/ /***********************************************************************/
void DTVAL::SetTimeShift(void) void DTVAL::SetTimeShift(void)
{ {
struct tm dtm = {0,0,0,2,0,70,0,0,0}; struct tm dtm = {0,0,0,2,0,70,0,0,0,0,0};
Shift = (int)mktime(&dtm) - 86400; Shift = (int)mktime(&dtm) - 86400;
...@@ -1257,7 +1273,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) ...@@ -1257,7 +1273,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval)
int i, m; int i, m;
int n; int n;
bool rc = false; bool rc = false;
struct tm datm = {0,0,0,1,0,70,0,0,0}; struct tm datm = {0,0,0,1,0,70,0,0,0,0,0};
if (trace) if (trace)
htrc("MakeDate from(%d,%d,%d,%d,%d,%d) nval=%d\n", htrc("MakeDate from(%d,%d,%d,%d,%d,%d) nval=%d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment