Suppress some more valgrind whining about btree_gist.

A couple of functions didn't bother to zero out pad bytes in datums that
would ultimately go to disk.  Harmless, but valgrind doesn't know that.
This commit is contained in:
Tom Lane 2014-05-16 15:29:02 -04:00
parent 39586bc1e9
commit af215d8190
1 changed files with 10 additions and 8 deletions

View File

@ -70,19 +70,21 @@ GBT_VARKEY *
gbt_var_key_copy(const GBT_VARKEY_R *u, bool force_node)
{
GBT_VARKEY *r = NULL;
int32 lowersize = VARSIZE(u->lower);
int32 uppersize = VARSIZE(u->upper);
if (u->lower == u->upper && !force_node)
{ /* leaf key mode */
r = (GBT_VARKEY *) palloc(VARSIZE(u->lower) + VARHDRSZ);
memcpy(VARDATA(r), u->lower, VARSIZE(u->lower));
SET_VARSIZE(r, VARSIZE(u->lower) + VARHDRSZ);
r = (GBT_VARKEY *) palloc(lowersize + VARHDRSZ);
memcpy(VARDATA(r), u->lower, lowersize);
SET_VARSIZE(r, lowersize + VARHDRSZ);
}
else
{ /* node key mode */
r = (GBT_VARKEY *) palloc(INTALIGN(VARSIZE(u->lower)) + VARSIZE(u->upper) + VARHDRSZ);
memcpy(VARDATA(r), u->lower, VARSIZE(u->lower));
memcpy(VARDATA(r) + INTALIGN(VARSIZE(u->lower)), u->upper, VARSIZE(u->upper));
SET_VARSIZE(r, INTALIGN(VARSIZE(u->lower)) + VARSIZE(u->upper) + VARHDRSZ);
r = (GBT_VARKEY *) palloc0(INTALIGN(lowersize) + uppersize + VARHDRSZ);
memcpy(VARDATA(r), u->lower, lowersize);
memcpy(VARDATA(r) + INTALIGN(lowersize), u->upper, uppersize);
SET_VARSIZE(r, INTALIGN(lowersize) + uppersize + VARHDRSZ);
}
return r;
}
@ -201,7 +203,7 @@ gbt_var_node_truncate(const GBT_VARKEY *node, int32 cpf_length, const gbtree_vin
len2 = Min(len2, (cpf_length + 1));
si = 2 * VARHDRSZ + INTALIGN(len1 + VARHDRSZ) + len2;
out = (GBT_VARKEY *) palloc(si);
out = (GBT_VARKEY *) palloc0(si);
SET_VARSIZE(out, si);
memcpy(VARDATA(out), r.lower, len1 + VARHDRSZ);