diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-05-16 15:29:02 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-05-16 15:29:02 -0400 |
commit | af215d8190e6ab170c02c24afd1be81f5a147481 (patch) | |
tree | 5a5b853fd6f384205e251af7fc073e2bf055f33d /contrib/btree_gist/btree_utils_var.c | |
parent | 39586bc1e971c136c4487b26eb7334dbbe23b102 (diff) | |
download | postgresql-af215d8190e6ab170c02c24afd1be81f5a147481.tar.gz postgresql-af215d8190e6ab170c02c24afd1be81f5a147481.zip |
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.
Diffstat (limited to 'contrib/btree_gist/btree_utils_var.c')
-rw-r--r-- | contrib/btree_gist/btree_utils_var.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index 09b51fc9c99..b7dd060a944 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -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); |