From: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
---|---|
To: | nathandbossart(at)gmail(dot)com |
Cc: | dgrowleyml(at)gmail(dot)com, gurjeet(at)singh(dot)im, pgsql-hackers(at)postgresql(dot)org, michael(at)paquier(dot)xyz, andrew(at)dunslane(dot)net |
Subject: | Re: Proposal: add new API to stringinfo |
Date: | 2025-01-10 02:31:34 |
Message-ID: | 20250110.113134.2213387094257116559.ishii@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> 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
Attachment | Content-Type | Size |
---|---|---|
v4-0001-Add-new-StringInfo-APIs-to-allow-callers-to-speci.patch | application/octet-stream | 5.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andy Fan | 2025-01-10 02:45:21 | pgbench error: (setshell) of script 0; execution of meta-command failed |
Previous Message | Michael Paquier | 2025-01-10 01:46:46 | Re: Make pg_stat_io view count IOs as bytes instead of blocks |