diff options
author | Daniel Gustafsson <dgustafsson@postgresql.org> | 2024-03-16 23:18:28 +0100 |
---|---|---|
committer | Daniel Gustafsson <dgustafsson@postgresql.org> | 2024-03-16 23:18:28 +0100 |
commit | b7831865159d5fb6f0d263e6023f0986589fe254 (patch) | |
tree | f6525ed20cab8159e66d39a0fd7e5ca754bf21aa /src/backend/utils/adt/xml.c | |
parent | 927332b95e778c0d15a9fbf96e3efeab0d3d937c (diff) | |
download | postgresql-b7831865159d5fb6f0d263e6023f0986589fe254.tar.gz postgresql-b7831865159d5fb6f0d263e6023f0986589fe254.zip |
Add destroyStringInfo function for cleaning up StringInfos
destroyStringInfo() is a counterpart to makeStringInfo(), freeing a
palloc'd StringInfo and its data. This is a convenience function to
align the StringInfo API with the PQExpBuffer API. Originally added
in the OAuth patchset, it was extracted and committed separately in
order to aid upcoming JSON work.
Author: Daniel Gustafsson <daniel@yesql.se>
Author: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAOYmi+mWdTd6ujtyF7MsvXvk7ToLRVG_tYAcaGbQLvf=N4KrQw@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/xml.c')
-rw-r--r-- | src/backend/utils/adt/xml.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index beecd0c2ac1..3e4ca874d81 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -2163,8 +2163,7 @@ xml_errorHandler(void *data, PgXmlErrorPtr error) appendBinaryStringInfo(&xmlerrcxt->err_buf, errorBuf->data, errorBuf->len); - pfree(errorBuf->data); - pfree(errorBuf); + destroyStringInfo(errorBuf); return; } @@ -2195,8 +2194,7 @@ xml_errorHandler(void *data, PgXmlErrorPtr error) (errmsg_internal("%s", errorBuf->data))); } - pfree(errorBuf->data); - pfree(errorBuf); + destroyStringInfo(errorBuf); } |