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 1vRVJn-00EiHI-08 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Dec 2025 12:53:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRVJk-007xIn-22 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Dec 2025 12:53:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRVJk-007xIP-13 for pgsql-hackers@lists.postgresql.org; Fri, 05 Dec 2025 12:53:48 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vRVJh-003HFi-35 for pgsql-hackers@postgresql.org; Fri, 05 Dec 2025 12:53:47 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-341988c720aso1643633a91.3 for ; Fri, 05 Dec 2025 04:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764939225; x=1765544025; 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=IqZE09pPxscO1yOxfqCUsLZceKP4ymepXg0sD/dHUVg=; b=MIMLlutXX73YEM0cnRE40IxWWqOjWitT3zc0E/vSDz6jZwMhLCNWiXYBf2YS9mEEi9 1bas8kPCQh/C+h37/zA3nF3XSd+s7Oq6xpyfMxg4/aIJpPBbBquOzA2pKqm/PcK5hQHy rjY0HWqqdUV+DRCOmesVu6l3jd6kflBE8Wl1Mxco9uWftCJwdBG+i3jz5i01mrxonfEG 5gqp5SRkCfITy8JitgdL4g017eRFF6upzukjsKxGrUZGo8EBibLnfSiHiA76Jf6S8DSV 4D2H/I/Dw6sbitK0PvjXIwoo4DyAq8ufrT29E5yrbbul2+ez2OhD16R+LY3odG1m/Xkq 0qAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764939225; x=1765544025; 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=IqZE09pPxscO1yOxfqCUsLZceKP4ymepXg0sD/dHUVg=; b=bLpJBizlIwwyKNPRkgVUjf5MLlVtoQuoSxaXCdCc0vyE02sIONWC3HiAIF3C0i9/Nz +FqBzlPl3VQYaSKI4+z4imEPosE1Mm5mjYLmr8yOq/1P7ym+FbAlRES4d0VTBnkSo71g BkvcV1PkeNWfiC9q7NbgPajIKNPQVQ9HL2bVjb7GRD+nV6bYa4d7EGMI84xw/n6OTlNr F919RGJ9gE8e6iWA3i/wNXMEyVAyRBjJiXg2lT4OcXiLjsIEl8ZgY5hzO88boZaJYPcd c6HfkP/ebWdNF2iVRjoTRdJ+DMWIvpGfwfsFX1GOpWjUS9/UCSrLmya17EqR7F4xWdjC Jheg== X-Forwarded-Encrypted: i=1; AJvYcCXIYZgY05lghCpsp5SVF9Lj+KASiy4ZcKJnw3AVzJS/56HlxPhSHnCTV36i2N3apPSNqwQHRljq+c0G9dCK@postgresql.org X-Gm-Message-State: AOJu0YweuaE77IE9uM5LbkzKOh7LN10AUCJw01ZR2F+AkwCmyACpJIJM eJd2daXbsk3uzLYfphWQVGvEGatlwJBnI8P+ONp0PdjC44CqJJ482iIu2rMGyhd5Wzo= X-Gm-Gg: ASbGncsXUO3cVBAo5+fI8HyHbLLyXVfuy3Z7R3zr1YwyE7E0HJ1rW5VufdCVKpHMAaU LjNWdRRbNg/9uRN1CZI93IuIXO2m1pTE6eYAtY1ybqWpkSeYCNXOF/p/oMiV2rY9k7lovlSYV5/ KGuCjHJkZywlzk/MjuXuQsDHjnQth7vA+OdLb0C9YMLvptQGJt49osASep70AdCcHmk+Sx7eLAu QWSRLJgTPI1zAtU/1mWz4oUHaIZva9llULViN23zKvPFp4cU69J6N91kUKceAZ57jfoo5PSuplF 53mlXA3Ez5QEe4axEm7woPOsyrquWheNgq+jqHtVbEPMsSWJIjUTo5NIfNJiB35WIuJnCAtb8PV EQM0WW8JpW9Pqz+F6GMvxebJdkHVAgHD2UJYlLvaUciq44zbMjHFSiNipUFWhwBdx1T6JTbgrKN Qqo3T+8VLnOvzGBfMe/yJY/1wgE3QFXtKz4ev+A+SbZaYi58vzZAC7pbPtDdCjzbGLPiI= X-Google-Smtp-Source: AGHT+IG+8EJywHwroF4Qvx6MczYUs7R4OvF8IpOYN8UmFMOCoExjMBot8DxJpav9Vi+JFXHuIEVNZw== X-Received: by 2002:a17:90b:3810:b0:340:f05a:3ec3 with SMTP id 98e67ed59e1d1-3491270120amr11188905a91.33.1764939225235; Fri, 05 Dec 2025 04:53:45 -0800 (PST) Received: from [10.255.187.72] (vip-148-139-2-229.cust.service-now.com. [148.139.2.229]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34912b5cd2asm4567676a91.1.2025.12.05.04.53.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Dec 2025 04:53:44 -0800 (PST) Message-ID: Date: Fri, 5 Dec 2025 13:53:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Consistently use palloc_object() and palloc_array() To: Michael Paquier Cc: Tom Lane , Thomas Munro , Chao Li , pgsql-hackers References: <524587.1764365323@sss.pgh.pa.us> <1e7f0c17-a965-4d5b-ad88-b435a4d97490@gmail.com> <143d3184-b575-49bd-8bc1-f37f45f010cc@gmail.com> <534126.1764722446@sss.pgh.pa.us> <4ab4a12b-49e9-4ebf-9055-225c8055fed0@gmail.com> Content-Language: en-US From: David Geier In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 05.12.2025 08:41, Michael Paquier wrote: > On Thu, Dec 04, 2025 at 10:31:41AM +0100, David Geier wrote: >> Attached are the two patches, rebased on latest master. >> >> The first one contains all changes that either result in no changes to >> the disassembly, or only in changes due to the line counts; because >> elog.h makes use of __LINE__. > > Thanks. That's a lot to digest. > > I have generated some reports by comparing builds of HEAD and > HEAD+0001 to indeed note that a lot of noise is caused by the line > number changes. And then, I have begun looking at contrib/ to start > with something as I had a bit of time today. One part which we need > to be careful about is that the allocations map with the actual > declarations, and I'm doubting my compiler to detect all of them, so > visual check for each path it is... > > - void *out = palloc(sizeof(float4KEY)); > + void *out = palloc_object(float4KEY); > > btree_gist/ has a bunch of these, which I guess don't really matter in > terms of type safety. > > - sv = palloc(sizeof(bytea *) * (maxoff + 1)); > + sv = palloc_array(bytea *, (maxoff + 1)); > > This one also in gbt_var_picksplit@btree_utils_var.c. We have a > GBT_VARKEY. > > + keys = (char **) palloc_array(char *, key_count); > + values = (char **) palloc_array(char *, val_count); > > These two should not need casts. > > - stack = palloc(sizeof(*stack)); > + stack = palloc_object(sepgsql_proc_stack); > > This one in sepgsql was wrong, that can be detected with a compilation > of the module. My bad. I hadn't realized that - obviously - not necessarily all code is actually compiled by default. Will the build system enable any target for which all dependencies (e.g. libraries) are met, or are there targets that need to be enabled explicitly? Is there a way to enable all of them so I can easily make sure, I actually compile all code? > And done with the contrib/ part for the trival changes. Thanks for applying the first batch of changes. -- David Geier