1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- 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; PCOLDEF cdp, lcdp= NULL, tocols= NULL;
PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO)); PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO));
memset(pcf, 0, sizeof(COLINFO));
// Get a unique char identifier for type // Get a unique char identifier for type
tc= (defp->Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX; 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) void CHRBLK::Move(int i, int j)
{ {
memcpy(Chrp + j * Long, Chrp + i * Long, Long); if (i != j) {
MoveNull(i, j); memcpy(Chrp + j * Long, Chrp + i * Long, Long);
MoveNull(i, j);
} // endif i
} // end of Move } // end of Move
/***********************************************************************/ /***********************************************************************/

View File

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