summaryrefslogtreecommitdiff
path: root/src/common/stringinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/stringinfo.c')
-rw-r--r--src/common/stringinfo.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/stringinfo.c b/src/common/stringinfo.c
index c61d5c58f30..ec5fc2422d8 100644
--- a/src/common/stringinfo.c
+++ b/src/common/stringinfo.c
@@ -350,3 +350,19 @@ enlargeStringInfo(StringInfo str, int needed)
str->maxlen = newlen;
}
+
+/*
+ * destroyStringInfo
+ *
+ * Frees a StringInfo and its buffer (opposite of makeStringInfo()).
+ * This must only be called on palloc'd StringInfos.
+ */
+void
+destroyStringInfo(StringInfo str)
+{
+ /* don't allow destroys of read-only StringInfos */
+ Assert(str->maxlen != 0);
+
+ pfree(str->data);
+ pfree(str);
+}