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

@@ -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
/***********************************************************************/