Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vP5fu-003u9C-1Z for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 21:06:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vP5fs-00DZ4v-27 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 21:06:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vP5fs-00DZ4n-0s for pgsql-hackers@lists.postgresql.org; Fri, 28 Nov 2025 21:06:40 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vP5fq-0023D9-1r for pgsql-hackers@postgresql.org; Fri, 28 Nov 2025 21:06:40 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b735b7326e5so560526366b.0 for ; Fri, 28 Nov 2025 13:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764363997; x=1764968797; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=sygd3ZBoTj9e4IzuKcDfgGsmYHjojUpYSf3yIbRcv3A=; b=HROOOzvm0pfD0tUV4xBkc10V4q5zag9D2AZlWM5dfoIamDIpOKcIxUuLh4mokHAoUC hGVfQ69Ta+5t4dv/+ewLFLTJHVXkdkZzlKz8MAl92XuNqZ5LPY4wMBdanA/K/UGQ++40 W6aVaA5WjyqIiQQ9fvkH9fJLAzwpJvdWzWWMDanUO0T/V8UhIvxldSUP28LJ6tdjGUXT X9t6TDovcaB+Pz46CIJQY33kwJEzp3Jk7DNI4FoJYx0Zfwd26OhQptNP8LfhLR6qB8PS sJkVsUKo6Yw//zfFLtFIzJ5T6HXufrETDTRdEsvsfylQNy3nZ0lruHqVLNHONFBn5e1X kCNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764363997; x=1764968797; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sygd3ZBoTj9e4IzuKcDfgGsmYHjojUpYSf3yIbRcv3A=; b=Q1+T0YPDhqCAkNdO6xvHY/zefg3COjnvQ8YRgkL81IEllRgHf/aT8FNIiDNSjaG9dq PJQN+JtzxVTpaoY5UoQZH0E9tx7gBZLD5xbDVOWbYJi+y0ca74krrEh9NKbf1PzyO3p9 kGU/MsOc3OvKq0fL9ZRz1xlxf8Fbd0kHEe61IBSvMCnR1+AO7bri8cb7DIrJdw6/Rjj8 rbSlHjRsWPx2NhYxlWZkoNQSVOZO2ohaZTX6Cs4m8OIlxK7k7xbAENZm+VxVrnQykaZC Dg9qIrQslCQCqkYYofon87jFDykG80jtUiSyQCxdOrq4GCDNgkfH0quqQRg7QhrddEFw sXyw== X-Gm-Message-State: AOJu0YzWAptIv5YnDhWzbsHROAdEhRuxMWDjdOiz0/mNnOmpY/FU8Xq2 p5nXMqjIB+z5VDHpwEIHW6+7b+00ctJ8RPO44uJ4eRXgizXBLaGGKu6Wsspyzg== X-Gm-Gg: ASbGncvXM39uzXdu+w7M9cMp9leBkpKRafvc2SL8atzUgbG8Hn+XCOy+DYHxAOZM8Ql C3jyIsiK+p5AV2i2zatq/pz3kDVb9qG8q6BaIHsE5Xuu/lsQuQ2y5+0MS2n7u76RDe4DTjeP2fx ybOZwkceiQ8/brrF/irbqUoJFkN1U4mrLSKcJ/lTjpfjmm9ahf/YpW72MTphm1+q418RrMrDLeY xZoO/3z5r29vMLLR+d6tz4/DMaETEzfVzlgYzv6kyrA3Dht9LEGUGUvI5Il8zGWJcxlH/QI2yGq AQtcxCl4C6OXMvG+b4ncdIHHKqlackE6bFUdJqNC/mloLJqyPK3opazcIM+0O6KzkdGN3M+j9+D Axdermi6mvWHBU/l65mal8GURREaYxILa2xbX0xIn7DeWV4NnTueWvwfUD+BrhyKBv3DQyEbAHZ 6mAr0Mc3yP7cRW2oY= X-Google-Smtp-Source: AGHT+IEDTVCriJCzRk/EFuzf5G6WxAkNdfQfB7BzpIlL5MHP6ARFcHdAqk4LbVUrI1wTmPXBxD/URQ== X-Received: by 2002:a17:906:d54a:b0:b72:6a39:49e6 with SMTP id a640c23a62f3a-b766ef1d09fmr3615415666b.18.1764363996526; Fri, 28 Nov 2025 13:06:36 -0800 (PST) Received: from [192.168.2.32] ([165.225.27.7]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b76f5a265d4sm532293366b.60.2025.11.28.13.06.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Nov 2025 13:06:36 -0800 (PST) Message-ID: Date: Fri, 28 Nov 2025 22:06:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Consistently use palloc_object() and palloc_array() To: Chao Li Cc: pgsql-hackers References: Content-Language: en-US From: David Geier In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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