Skip to content

Commit 4079d52

Browse files
author
Nikita Glukhov
committed
Add JsonContainerAlloc() macro
1 parent 28ed5bb commit 4079d52

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/backend/utils/adt/json_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ JsonValueToContainer(const JsonValue *val)
173173
return val->val.binary.data;
174174
else
175175
{
176-
JsonContainerData *jc = palloc(sizeof(JsonContainerData));
176+
JsonContainerData *jc = JsonContainerAlloc();
177177
jsonvInitContainer(jc, val);
178178
return jc;
179179
}

src/backend/utils/adt/jsonb_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ fillJsonbValue(const JsonbContainer *container, int index,
641641
{
642642
Assert(JBE_ISCONTAINER(entry));
643643
result->type = jbvBinary;
644-
result->val.binary.data = palloc(sizeof(JsonContainerData));
644+
result->val.binary.data = JsonContainerAlloc();
645645
jsonbInitContainer((JsonContainerData *) result->val.binary.data,
646646
/* Remove alignment padding from data pointer and length */
647647
(JsonbContainer *)(base_addr + INTALIGN(offset)),

src/common/jsonapi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,7 @@ jsontFillValue(JsonIterator **pit, JsonValue *res, bool skipNested,
13361336

13371337
res->type = jbvBinary;
13381338
res->val.binary.len = 0;
1339-
res->val.binary.data = (JsonContainer *)
1340-
palloc(sizeof(JsonContainer));
1339+
res->val.binary.data = JsonContainerAlloc();
13411340

13421341
if (skipNested)
13431342
{

src/include/utils/json_generic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ JsonIteratorNext(JsonIterator **it, JsonValue *val, bool skipNested)
249249

250250
extern Json *DatumGetJson(Datum value, JsonContainerOps *ops);
251251

252+
#define JsonContainerAlloc() \
253+
((JsonContainerData *) palloc(sizeof(JsonContainerData)))
254+
252255
extern JsonValue *JsonFindValueInContainer(JsonContainer *json, uint32 flags,
253256
JsonValue *key);
254257

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