From efc0eabd6019406ff92286a36713d41a42515e09 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 25 Jan 2011 09:49:59 +0000 Subject: Simplify XML parsing a bit. * xml-support.h (gdb_xml_parse_quick): Declare. * xml-support.c (gdb_xml_create_parser_and_cleanup_1): Renamed from gdb_xml_create_parser_and_cleanup, and added `old_chain' parameter. (gdb_xml_create_parser_and_cleanup): Reimplement on top of gdb_xml_create_parser_and_cleanup_1. (gdb_xml_parse_quick): New. * memory-map.c (parse_memory_map): Use gdb_xml_parse_quick. * osdata.c (osdata_parse): Ditto. * remote.c (remote_threads_info): Ditto. * solib-target.c (solib_target_parse_libraries): Ditto. * xml-syscall.c (syscall_parse_xml): Ditto. * xml-tdesc.c (tdesc_parse_xml): Ditto. --- gdb/memory-map.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'gdb/memory-map.c') diff --git a/gdb/memory-map.c b/gdb/memory-map.c index d10419c8e59..77389eb9938 100644 --- a/gdb/memory-map.c +++ b/gdb/memory-map.c @@ -178,25 +178,22 @@ const struct gdb_xml_element memory_map_elements[] = { VEC(mem_region_s) * parse_memory_map (const char *memory_map) { - struct gdb_xml_parser *parser; VEC(mem_region_s) *result = NULL; - struct cleanup *before_deleting_result, *back_to; + struct cleanup *back_to; struct memory_map_parsing_data data = { NULL }; - back_to = make_cleanup (null_cleanup, NULL); - parser = gdb_xml_create_parser_and_cleanup (_("target memory map"), - memory_map_elements, &data); - - /* Note: 'clear_result' will zero 'result'. */ - before_deleting_result = make_cleanup (clear_result, &result); data.memory_map = &result; - - if (gdb_xml_parse (parser, memory_map) == 0) - /* Parsed successfully, don't need to delete the result. */ - discard_cleanups (before_deleting_result); + back_to = make_cleanup (clear_result, &result); + if (gdb_xml_parse_quick (_("target memory map"), NULL, memory_map_elements, + memory_map, &data) == 0) + { + /* Parsed successfully, keep the result. */ + discard_cleanups (back_to); + return result; + } do_cleanups (back_to); - return result; + return NULL; } #endif /* HAVE_LIBEXPAT */ -- cgit v1.2.1