Re: Proposal: add new API to stringinfo
Tatsuo Ishii <ishii@postgresql.org>
From: Tatsuo Ishii <ishii@postgresql.org>
To: nathandbossart@gmail.com
Cc: dgrowleyml@gmail.com, gurjeet@singh.im, pgsql-hackers@postgresql.org,
michael@paquier.xyz, andrew@dunslane.net
Date: 2025-01-10T02:31:34Z
Lists: pgsql-hackers
Attachments
- v4-0001-Add-new-StringInfo-APIs-to-allow-callers-to-speci.patch (application/octet-stream) patch v4-0001
> Looks generally reasonable to me.
Thanks for looking into the patch.
> +/*
> + * initStringInfoInternal
> + *
> + * Initialize a StringInfoData struct (with previously undefined contents)
> + * to describe an empty string.
> + * The initial memory allocation size is specified by 'initsize'.
> + * The valid range for 'initsize' is 1 to MaxAllocSize.
> + */
> +static inline void
> +initStringInfoInternal(StringInfo str, int initsize)
> +{
> + Assert(initsize > 0);
> +
> + str->data = (char *) palloc(initsize);
> + str->maxlen = initsize;
> + resetStringInfo(str);
> +}
>
> nitpick: Should we Assert(initsize <= MaxAllocSize) here, too?
Agreed. I have replaced the Assert with this in the attached v4 patch.
Assert(initsize >= 1 && initsize <= MaxAllocSize);
Note, I changed "initsize > 0" to "initsize >= 1" to better match with
the comment:
> * The valid range for 'initsize' is 1 to MaxAllocSize.
If there's no objection, I am going to commit the patch.
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 →
-
Add new StringInfo APIs to allow callers to specify the buffer size.
- a9dcbb4d5c00 18.0 landed