- Trying to get rid of some valgrind warnings

modified:
  storage/connect/mycat.cc
  storage/connect/valblk.cpp
  storage/connect/value.cpp
This commit is contained in:
Olivier Bertrand 2013-06-30 12:43:30 +02:00
parent 639ce0650c
commit b98360a42f
3 changed files with 51 additions and 22 deletions

View file

@ -426,6 +426,8 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
PCOLDEF cdp, lcdp= NULL, tocols= NULL;
PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO));
memset(pcf, 0, sizeof(COLINFO));
// Get a unique char identifier for type
tc= (defp->Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX;

View file

@ -654,8 +654,11 @@ void CHRBLK::SetValues(PVBLK pv, int k, int n)
/***********************************************************************/
void CHRBLK::Move(int i, int j)
{
memcpy(Chrp + j * Long, Chrp + i * Long, Long);
MoveNull(i, j);
if (i != j) {
memcpy(Chrp + j * Long, Chrp + i * Long, Long);
MoveNull(i, j);
} // endif i
} // end of Move
/***********************************************************************/

View file

@ -578,19 +578,25 @@ void TYPVAL<TYPE>::SetValue_char(char *p, int n)
template <>
void TYPVAL<double>::SetValue_char(char *p, int n)
{
char *p2, buf[32];
if (p) {
char *p2, buf[32];
for (p2 = p + n; p < p2 && *p == ' '; p++) ;
for (p2 = p + n; p < p2 && *p == ' '; p++) ;
n = min(p2 - p, 31);
memcpy(buf, p, n);
buf[n] = '\0';
Tval = atof(buf);
n = min(p2 - p, 31);
memcpy(buf, p, n);
buf[n] = '\0';
Tval = atof(buf);
if (trace > 1)
htrc(" setting double: '%s' -> %lf\n", buf, Tval);
if (trace > 1)
htrc(" setting double: '%s' -> %lf\n", buf, Tval);
Null = false;
} else {
Reset();
Null = Nullable;
} // endif p
Null = false;
} // end of SetValue
/***********************************************************************/
@ -599,8 +605,14 @@ void TYPVAL<double>::SetValue_char(char *p, int n)
template <class TYPE>
void TYPVAL<TYPE>::SetValue_psz(PSZ s)
{
Tval = GetTypedValue(s);
Null = false;
if (s) {
Tval = GetTypedValue(s);
Null = false;
} else {
Reset();
Null = Nullable;
} // endif p
} // end of SetValue
template <>
@ -895,17 +907,23 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/
void TYPVAL<PSZ>::SetValue_char(char *p, int n)
{
n = min(n, Len);
strncpy(Strp, p, n);
if (p) {
n = min(n, Len);
strncpy(Strp, p, n);
for (p = Strp + n - 1; (*p == ' ' || *p == '\0') && p >= Strp; p--) ;
for (p = Strp + n - 1; (*p == ' ' || *p == '\0') && p >= Strp; p--) ;
*(++p) = '\0';
*(++p) = '\0';
if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp);
if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp);
Null = false;
} else {
Reset();
Null = Nullable;
} // endif p
Null = false;
} // end of SetValue_char
/***********************************************************************/
@ -913,8 +931,14 @@ void TYPVAL<PSZ>::SetValue_char(char *p, int n)
/***********************************************************************/
void TYPVAL<PSZ>::SetValue_psz(PSZ s)
{
strncpy(Strp, s, Len);
Null = false;
if (s) {
strncpy(Strp, s, Len);
Null = false;
} else {
Reset();
Null = Nullable;
} // endif s
} // end of SetValue_psz
/***********************************************************************/