On Wed, Aug 16, 2023 at 9:24 PM Nathan Bossart <nathandboss...@gmail.com> wrote: > > On Wed, Aug 16, 2023 at 10:35:27AM +0700, John Naylor wrote:
> > Now I'm struggling to understand why each and every instance has its own > > nominal buffer, passed down to the implementation. All we care about is the > > result -- is there some reason not to confine the buffer declaration to the > > general implementation? > > We can do that if we use a static variable, which is what I've done in v6. That makes it a lexically-scoped global variable, which we don't need either. Can we have the internal function allocate on the stack, then call cstring_to_text() on that, returning the text result? That does its own palloc. Or maybe better, save the starting pointer, compute the length at the end, and call cstring_to_text_with_len()? (It seems we wouldn't need the nul-terminator then, either.) -- John Naylor EDB: http://www.enterprisedb.com