From: qinruyao (@qinruyao) <noreply+qinruyao@github.com>
To: pgbackrest/pgbackrest <noreply+pgbackrest-pgbackrest@github.com>
Subject: Re: [pgbackrest/pgbackrest] PR #2896: Add S3 KMS encryption context option.
Date: Wed, 04 Nov 2026 19:17:44 +0000
Message-ID: <gh-pgbackrest-pgbackrest-2896-rc4472166486@github.com> (raw)
In-Reply-To: <gh-pgbackrest-pgbackrest-2896-rc4468833752@github.com>
References: <gh-pgbackrest-pgbackrest-2896@github.com>
<gh-pgbackrest-pgbackrest-2896-rc4468833752@github.com>
(on src/storage/s3/storage.c:1411)
The memory-context macros freed the intermediate objects immediately. Since this runs once per storage instance, I’ve removed them to simplify the code in the new PR iteration.
I kept the two statements because BUFSTR expands its argument three times. Inlining the conversion would repeat the map copy and JSON serialization three times. Using a local variable evaluates that expression once:
```
const String *const context = jsonFromVar(varNewKv(kvDup(kmsEncryptionContext)));
this->kmsEncryptionContext = strNewEncode(encodingBase64, BUFSTR(context));
```