From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7591 invoked by alias); 30 May 2013 17:41:17 -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 7581 invoked by uid 89); 30 May 2013 17:41:16 -0000 X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 30 May 2013 17:41:16 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4UHfE4b025712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 May 2013 13:41:15 -0400 Received: from barimba (ovpn-113-72.phx2.redhat.com [10.3.113.72]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4UHfDCZ011721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 30 May 2013 13:41:14 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: Re: [PATCH 40/40] fix up xml-support.c References: <28bbcf20b7b4a0f597237b56a7eb8793c65edbed.1368124285.git.tromey@redhat.com> Date: Thu, 30 May 2013 17:41:00 -0000 In-Reply-To: <28bbcf20b7b4a0f597237b56a7eb8793c65edbed.1368124285.git.tromey@redhat.com> (Tom Tromey's message of "Thu, 09 May 2013 12:53:10 -0600") Message-ID: <877gigs6va.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-05/txt/msg01092.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> xml-support.c has a function that returns a cleanup via an out parameter. Tom> This changes this function to be a normal cleanup constructor -- Tom> returning the cleanup directly and returning the other result via an Tom> out parameter. Pedro pointed out that gdb_xml_create_parser_and_cleanup_1 can be renamed back to gdb_xml_create_parser_and_cleanup now. So, I am checking in the appended version of this patch, which implements this change. Tom * xml-support.c (gdb_xml_create_parser_and_cleanup): Rename from gdb_xml_create_parser_and_cleanup_1. Return a cleanup. Remove 'old_chain' argument. Add 'parser_result' argument. (gdb_xml_create_parser_and_cleanup): Remove old version. (gdb_xml_parse_quick): Update. (xml_process_xincludes): Update. * xml-support.h (gdb_xml_create_parser_and_cleanup): Don't declare. diff --git a/gdb/xml-support.c b/gdb/xml-support.c index b777814..1682d8e 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -440,17 +440,18 @@ gdb_xml_cleanup (void *arg) xfree (parser); } -/* Initialize and return a parser. Register a cleanup to destroy the - parser. */ +/* Initialize a parser and store it to *PARSER_RESULT. Register a + cleanup to destroy the parser. */ -static struct gdb_xml_parser * -gdb_xml_create_parser_and_cleanup_1 (const char *name, - const struct gdb_xml_element *elements, - void *user_data, struct cleanup **old_chain) +static struct cleanup * +gdb_xml_create_parser_and_cleanup (const char *name, + const struct gdb_xml_element *elements, + void *user_data, + struct gdb_xml_parser **parser_result) { struct gdb_xml_parser *parser; struct scope_level start_scope; - struct cleanup *dummy; + struct cleanup *result; /* Initialize the parser. */ parser = XZALLOC (struct gdb_xml_parser); @@ -476,25 +477,8 @@ gdb_xml_create_parser_and_cleanup_1 (const char *name, start_scope.elements = elements; VEC_safe_push (scope_level_s, parser->scopes, &start_scope); - if (old_chain == NULL) - old_chain = &dummy; - - *old_chain = make_cleanup (gdb_xml_cleanup, parser); - return parser; -} - -/* Initialize and return a parser. Register a cleanup to destroy the - parser. */ - -struct gdb_xml_parser * -gdb_xml_create_parser_and_cleanup (const char *name, - const struct gdb_xml_element *elements, - void *user_data) -{ - struct cleanup *old_chain; - - return gdb_xml_create_parser_and_cleanup_1 (name, elements, user_data, - &old_chain); + *parser_result = parser; + return make_cleanup (gdb_xml_cleanup, parser); } /* External entity handler. The only external entities we support @@ -623,8 +607,8 @@ gdb_xml_parse_quick (const char *name, const char *dtd_name, struct cleanup *back_to; int result; - parser = gdb_xml_create_parser_and_cleanup_1 (name, elements, - user_data, &back_to); + back_to = gdb_xml_create_parser_and_cleanup (name, elements, + user_data, &parser); if (dtd_name != NULL) gdb_xml_use_dtd (parser, dtd_name); result = gdb_xml_parse (parser, document); @@ -897,7 +881,8 @@ xml_process_xincludes (const char *name, const char *text, obstack_init (&data->obstack); back_to = make_cleanup (xml_xinclude_cleanup, data); - parser = gdb_xml_create_parser_and_cleanup (name, xinclude_elements, data); + gdb_xml_create_parser_and_cleanup (name, xinclude_elements, + data, &parser); parser->is_xinclude = 1; data->include_depth = depth; diff --git a/gdb/xml-support.h b/gdb/xml-support.h index a319678..a3a15ca 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -171,13 +171,6 @@ struct gdb_xml_element gdb_xml_element_end_handler *end_handler; }; -/* Initialize and return a parser. Register a cleanup to destroy the - parser. */ - -struct gdb_xml_parser *gdb_xml_create_parser_and_cleanup - (const char *name, const struct gdb_xml_element *elements, - void *user_data); - /* Associate DTD_NAME, which must be the name of a compiled-in DTD, with PARSER. */