Hi!

Thanks for taking a look.

On 27.11.2025 00:03, Chao Li wrote:
> 
> This is a large patch, I just take a quick look, and found that:
> 
> ```
> -             *phoned_word = palloc(sizeof(char) * strlen(word) + 1);
> +             *phoned_word = palloc_array(char, strlen(word) + 1);
> ```
> 
> And
> 
> ```
> -             params = (const char **) palloc(sizeof(char *));
> +             params = palloc_object(const char *);
> ```
> 
> Applying palloc_array and palloc_object to char type doesn’t seem to improve 
> anything.
> 

You mean because sizeof(char) is always 1 and hence we could instead
simply write:

*phoned_word = palloc(strlen(word) + 1);
params = palloc(1);

I think the _array and _object variants are more expressive and for sure
don't make the code less readable.

--
David Geier


Reply via email to