Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite46e50f

Browse files
author
Nikita Glukhov
committed
Add JsonContainerFree()
1 parent5d6b800 commite46e50f

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)(StringInfoout,JsonContainer*jc,
6363
intestimated_len);
6464
JsonContainer*(*copy)(JsonContainer*jc);
65+
void*(*free)(JsonContainer*jc);
6566
};
6667

6768
typedefstructCompressedObject
@@ -164,6 +165,12 @@ typedef JsonContainer JsonbContainer;
164165
#defineJsonCopy(jscontainer) \
165166
JsonOp0(copy, jscontainer)
166167

168+
#defineJsonContainerFree(jc) do { \
169+
if ((jc)->ops->free) \
170+
(jc)->ops->free(jc); \
171+
} while (0)
172+
173+
167174
staticinlineJsonIteratorToken
168175
JsonIteratorNext(JsonIterator**it,JsonValue*val,boolskipNested)
169176
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp