From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24102 invoked by alias); 27 Feb 2009 21:13:38 -0000 Received: (qmail 24078 invoked by uid 22791); 27 Feb 2009 21:13:37 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Feb 2009 21:13:28 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n1RLDRIt024781 for ; Fri, 27 Feb 2009 16:13:27 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n1RLDQrb031686; Fri, 27 Feb 2009 16:13:27 -0500 Received: from localhost.localdomain (vpn-6-77.fab.redhat.com [10.33.6.77]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n1RLDPFb021392; Fri, 27 Feb 2009 16:13:26 -0500 Message-ID: <49A85774.5090200@redhat.com> Date: Fri, 27 Feb 2009 22:11:00 -0000 From: Phil Muldoon User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: tromey@redhat.com CC: gdb-patches@sourceware.org Subject: Re: [patch] valprint.c (read_string): Rework clean-up logic. References: <49A82F5C.9000801@redhat.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------000804050802040006000706" 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: 2009-02/txt/msg00500.txt.bz2 This is a multi-part message in MIME format. --------------000804050802040006000706 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 259 Tom Tromey wrote: > > Phil> + old_chain = make_cleanup (xfree_gdb_byte, buffer); > > ... and you can just s/xfree_gdb_byte/free_current_contents/ here. > > It is ok with that change. Thanks. > > Tom > Done. I attached the modified patch for reference. --------------000804050802040006000706 Content-Type: text/x-patch; name="read_string_cleanup-cvs2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="read_string_cleanup-cvs2.patch" Content-length: 1351 Index: valprint.c =================================================================== RCS file: /cvs/src/src/gdb/valprint.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- valprint.c 5 Feb 2009 12:16:25 -0000 1.79 +++ valprint.c 27 Feb 2009 19:33:06 -0000 1.80 @@ -1226,13 +1226,14 @@ some error, such as bumping into the end of the address space. */ found_nul = 0; - old_chain = make_cleanup (null_cleanup, 0); + *buffer = NULL; + + old_chain = make_cleanup (free_current_contents, buffer); if (len > 0) { *buffer = (gdb_byte *) xmalloc (len * width); bufptr = *buffer; - old_chain = make_cleanup (xfree, *buffer); nfetch = partial_memory_read (addr, bufptr, len * width, &errcode) / width; @@ -1243,8 +1244,6 @@ { unsigned long bufsize = 0; - *buffer = NULL; - do { QUIT; @@ -1253,13 +1252,9 @@ if (*buffer == NULL) *buffer = (gdb_byte *) xmalloc (nfetch * width); else - { - discard_cleanups (old_chain); - *buffer = (gdb_byte *) xrealloc (*buffer, - (nfetch + bufsize) * width); - } + *buffer = (gdb_byte *) xrealloc (*buffer, + (nfetch + bufsize) * width); - old_chain = make_cleanup (xfree, *buffer); bufptr = *buffer + bufsize * width; bufsize += nfetch; --------------000804050802040006000706--