diff options
author | Neil Conway <neilc@samurai.com> | 2007-03-03 19:32:55 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2007-03-03 19:32:55 +0000 |
commit | 90d76525c5cc2f3f4781351a1d99be839dfa2874 (patch) | |
tree | 75ee2db58298898533663d779d711879c43edb8d /contrib/tablefunc | |
parent | 053981f4054f6dfcda0ce65566605b49ca366a97 (diff) | |
download | postgresql-90d76525c5cc2f3f4781351a1d99be839dfa2874.tar.gz |
Add resetStringInfo(), which clears the content of a StringInfo, and
fixup various places in the tree that were clearing a StringInfo by hand.
Making this function a part of the API simplifies client code slightly,
and avoids needlessly peeking inside the StringInfo interface.
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; |