Re: Proposal: add new API to stringinfo

Tatsuo Ishii <ishii@postgresql.org>

From: Tatsuo Ishii <ishii@postgresql.org>
To: pgsql-hackers@postgresql.org
Cc: michael@paquier.xyz, dgrowleyml@gmail.com, andrew@dunslane.net, gurjeet@singh.im
Date: 2025-01-04T04:54:39Z
Lists: pgsql-hackers

Attachments

>> With opinions from Michael and David , what about following additional
>> APIs?
>>
>> #define STRINGINFO_DEFAULT_SIZE 1024 /* default initial allocation size
>> #*/
>> #define STRINGINFO_SMALL_SIZE 64 /* small initial allocation size */
>>
>> #define makeStringInfo makeStringInfoExtended(STRINGINFO_DEFAULT_SIZE)
>> #define initStringInfo(str) initStringInfoExtended(str,
>> #STRINGINFO_DEFAULT_SIZE)
>>
>> extern StringInfo makeStringInfoExtended(int initsize);
>> extern void initStringInfoExtended(StringInfo str, int initsize);
>>
> 
> 
> Seems like a good idea.

Thanks.

> Minor nit: the definition of the macro should contain parentheses, like so:
> #define makeStringInfo()   ....

Indeed. Thanks for pointing it out.

Attached is the patch for this.

Best reagards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add new StringInfo APIs to allow callers to specify the buffer size.