From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17790 invoked by alias); 17 Feb 2003 14:58:47 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17773 invoked from network); 17 Feb 2003 14:58:46 -0000 Received: from unknown (HELO localhost.redhat.com) (172.16.49.200) by 172.16.49.205 with SMTP; 17 Feb 2003 14:58:46 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 5B9323CF3; Sun, 16 Feb 2003 10:22:38 +0100 (CET) Message-ID: <3E4F585E.1020700@redhat.com> Date: Mon, 17 Feb 2003 14:58:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.1) Gecko/20021211 X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Carlton Cc: gdb Subject: Re: How much should I cleanup? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-02/txt/msg00254.txt.bz2 > When is it important to make sure that I have cleanups in place? My > understanding is that it's important if I have control of a block of > memory that I want to xfree() after doing some work, but where that > xfree() might not be reached because of exceptional circumstances. Just assume the exception is the norm - you're going to need to do a clean-up. The internals doco suggests several conventions. > So, if that's correct: what are 'exceptional circumstances'? I assume > error() and related functions count. I don't know exactly what QUIT > does; do I have to be careful if there are QUIT's in between the > xmalloc() and the xfree()? (Are those the only places where GDB pays > attention to ^C's?) Any other situations? Failed memory read, no frame. > Sigh. C has its benefits, but ease of memory management isn't one of > them. Every time I have to write a cleanup function, every time I > have to think about whether to alloca() memory for a string or to > xmalloc() it (and every time I can't alloca() it because I'm returning > the string in question), I get another grey hair. (Though the grey > hair falls out soon thereafter, for better or for worse.) Ah, yes. C++ `is the answer' :-^ > David Carlton > carlton@math.stanford.edu Andrew