From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17854 invoked by alias); 7 Mar 2006 08:24:58 -0000 Received: (qmail 17845 invoked by uid 22791); 7 Mar 2006 08:24:58 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 07 Mar 2006 08:24:56 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id k278OsP5021934; Tue, 7 Mar 2006 03:24:54 -0500 Received: from pobox.surrey.redhat.com (pobox.surrey.redhat.com [172.16.10.17]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id k278Or117308; Tue, 7 Mar 2006 03:24:53 -0500 Received: from [10.32.68.5] (vpn-68-5.surrey.redhat.com [10.32.68.5]) by pobox.surrey.redhat.com (8.12.8/8.12.8) with ESMTP id k278OoSF012718; Tue, 7 Mar 2006 08:24:52 GMT Message-ID: <440D45E5.6050001@redhat.com> Date: Tue, 07 Mar 2006 08:24:00 -0000 From: Nick Clifton User-Agent: Mozilla Thunderbird 1.0.7-1.4.1 (X11/20050929) MIME-Version: 1.0 To: ligang@sunnorth.com.cn CC: binutils@sourceware.org Subject: Re: question about memory allocate and free References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00085.txt.bz2 Hi Ligang, > 1. In Binutils source, the memory allcating functions are xmalloc() and > obstack_begin(). > but, a lot of allocated memory are not set free by free() or > obstack_free(). why? Bugs (mostly). Some times it is too difficult to know when it is safe to free the memory, but most of the time any failure to free allocated memory is a bug. > Dose it result in memory leak? Yes. Although probably not for very long. ie the memory is mostly likely needed right up until the BFD library has finished its work, at which point it is presumed that the client using the library will have finished its work as well, and so it will be terminating. > 2. In added files for porting Binutils, need i release allocated memeoy and > which > function should i use? bfd_alloc() and bfd_free() or their related functions. These are all defined in bfd/opncls.c. Cheers Nick