From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28729 invoked by alias); 23 Jan 2007 15:25:05 -0000 Received: (qmail 28672 invoked by uid 22791); 23 Jan 2007 15:25:02 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 23 Jan 2007 15:24:51 +0000 Received: (qmail 15613 invoked from network); 23 Jan 2007 15:24:49 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Jan 2007 15:24:49 -0000 To: gdb-patches@sourceware.org Subject: Re: [rfc] Plug memory leaks during gdbarch initialization References: <20070123144523.GA6339@nevyn.them.org> From: Jim Blandy Date: Tue, 23 Jan 2007 15:25:00 -0000 In-Reply-To: <20070123144523.GA6339@nevyn.them.org> (Daniel Jacobowitz's message of "Tue, 23 Jan 2007 09:45:23 -0500") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00479.txt.bz2 Daniel Jacobowitz writes: > The patch is an improvement, but doesn't fix that wart. I don't really > want to check it in without fixing the underlying problem but I don't > see a good way... anyone have a suggestion? I could imagine having each file's _initialize function start with: void _initialize_foo (void) { static initialized; if (initialized) return; initialized = 1; ... } A sed script could get the job done. Then, they could call each other with wild abandon. For extra points, you could do: void _initialize_foo (void) { static int initialized; assert (initialized != 1); if (initialized) return; initialized = 1; ... initialized = 2; } So you'd catch circular dependencies.