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/jsonb.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/jsonb.c')
-rw-r--r-- | src/backend/utils/adt/jsonb.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index a5e48744acb..a941654d5a3 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -133,8 +133,7 @@ jsonb_send(PG_FUNCTION_ARGS) pq_begintypsend(&buf); pq_sendint8(&buf, version); pq_sendtext(&buf, jtext->data, jtext->len); - pfree(jtext->data); - pfree(jtext); + destroyStringInfo(jtext); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } |