Skip to content

Commit e46e50f

Browse files
author
Nikita Glukhov
committed
Add JsonContainerFree()
1 parent 5d6b800 commit e46e50f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/backend/utils/adt/json_generic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ DatumGetJson(Datum value, JsonContainerOps *ops, Json *tmp)
130130
void
131131
JsonFree(Json *json)
132132
{
133+
JsonContainerFree(&json->root);
134+
133135
if (json->obj.freeValue)
134136
pfree(DatumGetPointer(json->obj.value));
135137

src/backend/utils/adt/jsonb_util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,4 +2229,5 @@ jsonbContainerOps =
22292229
NULL,
22302230
JsonbToCStringRaw,
22312231
JsonCopyFlat,
2232+
NULL,
22322233
};

src/include/utils/json_generic.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct JsonContainerOps
6262
char *(*toString)(StringInfo out, JsonContainer *jc,
6363
int estimated_len);
6464
JsonContainer *(*copy)(JsonContainer *jc);
65+
void *(*free)(JsonContainer *jc);
6566
};
6667

6768
typedef struct CompressedObject
@@ -164,6 +165,12 @@ typedef JsonContainer JsonbContainer;
164165
#define JsonCopy(jscontainer) \
165166
JsonOp0(copy, jscontainer)
166167

168+
#define JsonContainerFree(jc) do { \
169+
if ((jc)->ops->free) \
170+
(jc)->ops->free(jc); \
171+
} while (0)
172+
173+
167174
static inline JsonIteratorToken
168175
JsonIteratorNext(JsonIterator **it, JsonValue *val, bool skipNested)
169176
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy