From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 5C4B720282 for ; Sat, 10 Jun 2017 03:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751772AbdFJDVp (ORCPT ); Fri, 9 Jun 2017 23:21:45 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:50968 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbdFJDVp (ORCPT ); Fri, 9 Jun 2017 23:21:45 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 0C04720282; Sat, 10 Jun 2017 03:21:44 +0000 (UTC) Date: Sat, 10 Jun 2017 03:21:43 +0000 From: Eric Wong To: Junio C Hamano Cc: Jonathan Nieder , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , git@vger.kernel.org, Brandon Williams , Christian Couder , Martin =?utf-8?B?w4VncmVu?= Subject: Re: [PATCH v2 1/2] git-compat-util: add a FREEZ() wrapper around free(ptr); ptr = NULL Message-ID: <20170610032143.GA7880@starla> References: <20170609085346.19974-1-avarab@gmail.com> <20170609220420.4910-2-avarab@gmail.com> <20170609222738.GF21733@aiede.mtv.corp.google.com> <20170609233701.GA7195@whir> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Junio C Hamano wrote: > Eric Wong writes: > > I don't see the point of a macro wrapper, forcing the user to > > type out the '&' should drive home the point that the pointer > > gets set to NULL. I also find capitalization tiring-to-read > > because all characters are the same height. > > Sounds sensible. > > So make Jonathan's freez_impl a public API and rename it to > free_and_null(), perhaps? Perhaps... I think it needs to take "void *" to avoid warnings: static inline void free_and_null(void *ptrptr) { void **tmp = ptrptr; free(*tmp); *tmp = NULL; } ...At least I needed to do that for "mog_free_and_null" in cmogstored: https://bogomips.org/cmogstored.git/plain/alloc.c?h=v1.6.0 But heck, maybe that's covering up for something else I got wrong in cmogstored *shrug* I don't know all of C.