diff options
Diffstat (limited to 'contrib/tablefunc')
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 4e68428e0d..f3b1eb2a8b 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -1378,15 +1378,12 @@ build_tuplestore_recursively(char *key_fld, "incompatible."))); } + initStringInfo(&branchstr); + initStringInfo(&chk_branchstr); + initStringInfo(&chk_current_key); + for (i = 0; i < proc; i++) { - /* start a new branch */ - initStringInfo(&branchstr); - - /* need these to check for recursion */ - initStringInfo(&chk_branchstr); - initStringInfo(&chk_current_key); - /* initialize branch for this pass */ appendStringInfo(&branchstr, "%s", branch); appendStringInfo(&chk_branchstr, "%s%s%s", branch_delim, branch, branch_delim); @@ -1459,10 +1456,14 @@ build_tuplestore_recursively(char *key_fld, tupstore); /* reset branch for next pass */ - xpfree(branchstr.data); - xpfree(chk_branchstr.data); - xpfree(chk_current_key.data); + resetStringInfo(&branchstr); + resetStringInfo(&chk_branchstr); + resetStringInfo(&chk_current_key); } + + xpfree(branchstr.data); + xpfree(chk_branchstr.data); + xpfree(chk_current_key.data); } return tupstore; |