From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13510 invoked by alias); 30 Jan 2015 03:28:58 -0000 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 Received: (qmail 13500 invoked by uid 89); 30 Jan 2015 03:28:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 30 Jan 2015 03:28:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B3C5E11678F; Thu, 29 Jan 2015 22:28:52 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5JHDkVW+ZB8l; Thu, 29 Jan 2015 22:28:52 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 51F5411678D; Thu, 29 Jan 2015 22:28:52 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id C46B0491CD; Fri, 30 Jan 2015 07:28:48 +0400 (RET) Date: Fri, 30 Jan 2015 08:19:00 -0000 From: Joel Brobecker To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/6] Mention which return values need to be freed in lang_varobj_ops Message-ID: <20150130032848.GK5193@adacore.com> References: <1422559716-5480-1-git-send-email-simon.marchi@ericsson.com> <1422559716-5480-2-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422559716-5480-2-git-send-email-simon.marchi@ericsson.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-01/txt/msg00791.txt.bz2 > gdb/ChangeLog: > > * varobj.h (lang_varobj_ops): Mention which return values need > to be freed. Thanks for doing that! One question... > - /* The ``struct value *'' of the INDEX'th child of PARENT. */ > + /* The ``struct value *'' of the INDEX'th child of PARENT. The returned > + value must be freed by the caller. */ > struct value *(*value_of_child) (struct varobj *parent, int index); I'm really surprised by this. For memory management, the struct value objects are put on a chain. So, you wouldn't delete the value returned, but you would instead use "value_mark/value_free_to_mark". The top-level command loop takes a mark at the beginning of the command, and uses it to free any un-freed value after the command completes. But maybe you saw something that contradicts my understanding? -- Joel