Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2xwI-0002Ca-Oi for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Jun 2022 16:38:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o2xwH-0001x5-0f for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Jun 2022 16:38:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2xwF-0001wu-BX for pgsql-hackers@lists.postgresql.org; Sun, 19 Jun 2022 16:38:16 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2xwB-0001Fi-Kl for pgsql-hackers@postgresql.org; Sun, 19 Jun 2022 16:38:14 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B61CD5C009E; Sun, 19 Jun 2022 12:38:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 19 Jun 2022 12:38:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1655656686; x=1655743086; bh=q KGcdtmNelv2bIxV/BCi0qbnPgbIvOqzhFKDX2r3ycM=; b=OCYLnkRbdz7PLwDKc r/34mBiiuefxQy/rpGjZVmRGwv1XAICdUZaOxE2Rl9e7qdPloTSZ/CCYqBfDC/EH +8+ghodUkbzLAO+SQ/aCalDcvFsZZZb7SsnqXgYtXBPOYJDNMWMdDQKSud8RxIqC BouzwOu6qarwWocZfeQssc9bhcjVe2rzrIn7Oau2L/Lxm/IuUu1sPwm4rvY1Lmwe 9CWt6N9rPplp0P5Onq9e2GRtbuxFthDVS45/dnYEiEBDtdPz23/khqPTGoNgknoR B0zRmWve2tJNBIiWjvCpeU/GDZYlfGuiii/80vjwZMBhBvpSsSIVP2KGK8pFjq5A YktnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvledguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeej keffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghl vhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 19 Jun 2022 12:38:05 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 7A7D134F; Sun, 19 Jun 2022 11:55:33 +0200 (CEST) Date: Sun, 19 Jun 2022 11:55:33 +0200 From: Alvaro Herrera To: Peter Eisentraut Cc: Tom Lane , Michael Paquier , pgsql-hackers Subject: Re: libpq: Remove redundant null pointer checks before free() Message-ID: <20220619095533.7u35bbei3a2sswdm@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5eb1b215-acc2-9922-50d8-fc57a3e4f5e8@enterprisedb.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Jun-17, Peter Eisentraut wrote: > From 355ef1a68be690d9bb8ee0524226abd648733ce0 Mon Sep 17 00:00:00 2001 > From: Peter Eisentraut > Date: Fri, 17 Jun 2022 12:09:32 +0200 > Subject: [PATCH v2 3/3] Remove redundant null pointer checks before PQclear > and PQconninfofree > > These functions already had the free()-like behavior of handling NULL > pointers as a no-op. But it wasn't documented, so add it explicitly > to the documentation, too. For PQclear() specifically, one thing that I thought a few days ago would be useful would to have it return (PGresult *) NULL. Then the very common pattern of doing "PQclear(res); res = NULL;" could be simplified to "res = PQclear(res);", which is nicely compact and is learned instantly. I've not seen this convention used anywhere else though, and I'm not sure I'd advocate it for other functions where we use similar patterns such as pfree/pg_free, so perhaps it'd become too much of a special case. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/