1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

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
This commit is contained in:
Daniel Gustafsson
2024-03-16 23:18:28 +01:00
parent 927332b95e
commit b783186515
8 changed files with 31 additions and 17 deletions

View File

@ -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);
}