checking if jsonb was detoasted and releasing memory - Mailing list pgsql-general

From Igor Stassiy
Subject checking if jsonb was detoasted and releasing memory
Date
Msg-id CAKVOjexbsBBLRyzY3B3_DgohSMuJeqzXXoNVi562dNQ5vtN+-g@mail.gmail.com
Whole thread Raw
Responses Re: checking if jsonb was detoasted and releasing memory
List pgsql-general
Let us say that the datum of type Datum contains a Jsonb* type.
Then after the call

Jsonb *jb = DatumGetJsonb(datum);

the jb might point to a palloc'ed structure, in case detoasting took place. So the question is if this is the right way to free up the memory after checking that the jb was detoasted?

if ((void *)jb != DatumGetPointer(datum))
pfree(jb); // free if detoasted

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: Hardware requirements for a PostGIS server
Next
From: Tom Lane
Date:
Subject: Re: checking if jsonb was detoasted and releasing memory